Reputation: 1580
Suppose I have a linq expression that returns a sequence of IEnumerables. How do I concatenate them into a single flat IEnumerable? Concat seems to be limited to combining only two at a time.
Upvotes: 1
Views: 178
Reputation: 3603
What you're looking for is the SelectMany operator that will flatten an IEnumerable> in a single IEnumerable containing all T without materializing the results
IEnumerable<IEnumerable<string>> MyCollection = getdata();
IEnumerable<string> FlatenedData = MyCollection.SelectMany(item=>item);
Upvotes: 5