Answer the question
In order to leave comments, you need to log in
How to collect from a variable of type List(List(T)) a variable of type List(T) containing all elements using LINQ?
In the method, it became necessary to create a list from a list of lists with all elements from the parent lists.
List<List<int>> list = new List<List<int>>();
for (int i = 0; i < 10; i++)
{
list.Add(new List<int>());
for (int j = 0; j < 10; j++)
{
list[i].Add(i + j * 10);
}
}
var res = new List<int>();
foreach (var ll in list)
{
res.AddRange(ll);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question