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

后端 未结 12 2366
-上瘾入骨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:06

    Use the following after the loop.

    .TrimEnd(',')
    

    or simply change to

    string commaSeparatedList = input.Aggregate((a, x) => a + ", " + x)
    

提交回复
热议问题