Best way to remove the last character from a string built with stringbuilder
问题 I have the following data.AppendFormat("{0},",dataToAppend); The problem with this is that I am using it in a loop and there will be a trialling comma. What is the best way to remove the trailing comma? Do I have to change data to a string the substring it? 回答1: The simplest and most efficient way is to perform this command: data.Length--; by doing this you move the pointer (i.e. last index) back one character but you don't change the mutability of the object. In fact, clearing a