Comma “izing” a list of items

前端 未结 10 1697
我寻月下人不归
我寻月下人不归 2021-02-04 08:53

Given a list of strings, what is the best method for concatenating these strings into a comma separated list with no comma at the end. (VB.NET or C#) (Using either StringBuilder

10条回答
  •  说谎
    说谎 (楼主)
    2021-02-04 09:53

    Does the solution have to use a StringBuilder or the Concat method?

    If not, you could use the static String.Join method. For example (in C#):

    string result = String.Join(",", items.ToArray());
    

    See my very similar question for more details on this.

提交回复
热议问题