开发者

LINQ select to single row

开发者 https://www.devze.com 2023-04-02 10:20 出处:网络
what is the LINQ way of doing a pivot such that rows are trasposed to one string? e.g. a select producing:

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

精彩评论

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