Dunc
Dunc

Reputation: 8078

Producing an amalgamated list using linq

I have a querable collection of objects.

Each object contains a list.

I want to produce a list containing each element from the lists of each object in the collection.

How can I do this using linq or otherwise?

Upvotes: 1

Views: 88

Answers (1)

SLaks
SLaks

Reputation: 888185

To flatten a nested list, use SelectMany:

IEnumerable<ChildType> flattened = list.SelectMany(o => o.ChildList);

Upvotes: 5

Related Questions