开发者

How to write `Aggregate` in `from .. in ..` notation?

开发者 https://www.devze.com 2023-04-11 23:21 出处:网络
How to write string result = strings.开发者_StackOverflow社区Aggregate(new StringBuilder(), (s, a) => s.AppendLine(a)).ToString();

How to write

string result = strings.开发者_StackOverflow社区Aggregate(new StringBuilder(), (s, a) => s.AppendLine(a)).ToString();

in from a in strings select ... form?


You can't. See here for a list of LINQ query keywords:

http://msdn.microsoft.com/en-us/library/bb310804.aspx

However you do it you'd still need to call a method (Aggrigate).


How about a solution without the need for Aggregate at all:

    string[] strings = {"1", "2", "3"};
    string result = String.Join("\r", strings);
0

精彩评论

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