开发者

LINQ select to single row

what is the LINQ way of doing a pivot such that rows are trasposed to one string?

e.g.

a select producing:

a
b
c

would appear a开发者_运维百科s:

a,b,c


That sounds like you just want string.Join:

var results = string.Join(",", values);

No need for LINQ at all. Note that .NET 4 has more overloads for string.Join than earlier versions - so if you're using .NET 3.5 you may need something like:

var results = string.Join(",", values.Select(x => x.ToString()).ToArray());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜