How to list nested counters

I have a variable IEnumerable<IEnumerable<int>>. I am trying to somehow combine it in IEnumerable<int>, which lists all the integers in order. (All integers from the first set, then all integers from the second, etc.). I looked at the LINQ aggregation method, but the only examples I found were string concatenation, and I cannot figure out how to apply it here.

+3
source share
1 answer

You are looking for SelectManywhich can be used to smooth nested structures IEnumerable<T>in unsestedIEnumerable<T>

IEnumerable<IEnumerable<int>> enumerable;
IEnumerable<int> flat = enumerable.SelectMany(x => x);
+7
source

Source: https://habr.com/ru/post/1770955/


All Articles