List<int>[] a = new List<int>[10];
for (int i = 0; i <10; i++)
{
a[i] = new List<int>();
for (int ji = 0; ji < 5; ji++)
{
a[i].Add(ji * i); // adding some random int values to each list.
}
}
List<int> x = a.SelectMany(i => i.Select(j => j)).ToList();a is a list of list of integers and by nested for loops I am creating list of list of integers. And whenever we required, by doing selectmany (Lambda), we can combine the list together.Sometimes due to space constraints, certain complex algorithm design requires to have List of list of datatype. Here is the code snippet which demonstrates the scenario.
