List<int> listOfInt = new List<int>();
List<List<int>> listOfListOfInts = new List<List<int>>();
foreach (List<int> ints in listOfListOfInts)
{
foreach (int i in ints)
{
listOfInt.Add(i);
}
}
but using linq the following statements become:
List<int> listOfInt = listOfListOfInts.SelectMany(ints => ints).ToList();
1 comment:
Nice one. thanks very much for this post
Post a Comment