Wednesday 31 July 2013

List<string> to string

var strings = new List<string> { "blah", "de", "hoo", "ha" };

var result = strings.Aggregate((i, j) => i + " " + j);

Console.Write(result);
image001

And with a complex type, where a response has a collection of messages, each with a text property:

var messages = this.Response
.Messages
.Select(m => m.Text)
.Aggregate((i, j) => i + " " + j);

No comments:

Post a Comment