Is there any way to convert a collection of objects into a single new object using LINQ?
I want to use this within another LINQ to SQL expression.
Why don't you use the string.Join
itself?
string.Join("<br/>", collection.Select(e => e.TextProp).ToArray());
You can use the Aggregate method...
var myResults = (from myString in MyStrings
select myString)
.Aggregate(string.Empty, (results, nextString)
=> string.Format("{0}<br />{1}", results, nextString));
or
var myResults = MyStrings.Aggregate(string.Empty, (results, nextString)
=> string.Format("{0}<br />{1}", results, nextString));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With