If I have variable of type IEnumerable<List<string>> is there a LINQ statement or lambda expression I can apply to it which will combine the lists returning an IEnumerable<string>?
If I have variable of type IEnumerable<List<string>> is there a LINQ statement or lambda
Share
SelectMany – i.e.
For each item in someList, this then uses the lambda ‘x => x’ to get an IEnumerable<T> for the inner items. In this case, each ‘x’ is a List<T>, which is already IEnumerable<T>.
These are then returned as a contiguous block. Essentially, SelectMany is something like (simplified):
Although that is simplified somewhat.