输入:
var pList=new []{"a","b","c"};
输出:
string pListRet="a,b,c";
我知道它可以像JS
一样快速实现pList.Join(",");
但它可以用C#实现吗?
答案 0 :(得分:7)
var pList=new []{"a","b","c"};
string pListRet = String.Join(",",pList)
如果你真的真的想要使用linq,这可行:
var pList=new []{"a","b","c"};
string pListRet = pList.Aggregate((t,s) => t+(t==""?"":",")+s);