开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜