I’ve used this in the past to build comma seperated lists:
var list = new List<int>{1,2,3};
var retVal = list.Select(i=>i.ToString()).Aggregate((a,b) => a+", "+b);
Works great.
I’m trying to do the same sort of thing to ‘wrap’ each element as an xml node.
Something like:
Aggregate((a, b) => string.Format("<ID>{0}</ID><ID>{1}</ID>", a,b))
Can’t quite seem to make it work though. Is it possible? Or is there an easier way entirely?
Thanks.
Shouldn’t it be like:
You’re adding to
anew nodes.