C# in VS2005: problem with lists – Education Career Blog

public class MyClass {

   List<MyOtherClass> myInnerList;


Let’s say I have the following declared somewhere else:

List<MyClass> myOuterlist;

How would I quickly generate a list of the myInnerLists in C# using VS2005?


Why not a simple for loop?

List<List<MyOtherClass>> innerLists = new List<List<MyOtherClass>>();
for (int i = 0; i < myOuterList.Count; i++)


if you wanted to flatten the lists into a list of MyOtherClass:

List<MyOtherClass> list = m.SelectMany(x => x.myInnerList).ToList();

Leave a Comment