Best way to remove the last character from a string built with stringbuilder

后端 未结 12 2406
-上瘾入骨i
-上瘾入骨i 2020-12-23 14:30

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 t

12条回答
  •  醉话见心
    2020-12-23 15:04

    You should use the string.Join method to turn a collection of items into a comma delimited string. It will ensure that there is no leading or trailing comma, as well as ensure the string is constructed efficiently (without unnecessary intermediate strings).

提交回复
热议问题