.Net - Join together all item of a list in a output string

后端 未结 4 2159
南笙
南笙 2021-02-11 14:13

How can I write a Linq expression (or anything else) that select item from a List and join them together ?

Example

IList data = new List<         


        
4条回答
  •  孤独总比滥情好
    2021-02-11 14:42

    You can use aggregate when you need to join a list into a single aggregated object.

    string s = "";
    if(data.Count > 0)
      s = data.Aggregate((a, b) => a + ',' + b);
    

提交回复
热议问题