Printing a comma (,) after each item in an array

前端 未结 7 801
轮回少年
轮回少年 2020-12-20 17:28

Lets say I have an array (or list) of items

A[] = [a,b,c,d,e]

If I want to print them out so each item is separated by a comma (or any othe

7条回答
  •  一整个雨季
    2020-12-20 18:03

    You are looking for String.Join():

    var list = String.join(",", A);
    

    String.Join Method (String, String[])

     Concatenates all the elements of a string array, using the specified separator between each element.

    public static string Join(
        string separator,
        params string[] value
    )
    

提交回复
热议问题