EnumerateAllChildLists
ChoNestedList<T> provides a helper method to get all child list items.
1. Add reference to Cinchoo.Core.dll assembly
2. Namespace Cinchoo.Core.Collections.Generic
Sample code,
static void Main(string[] args) { ChoNestedList<int> topList = new ChoNestedList<int>(); topList.Add(1); topList.Add(2); ChoNestedList<int> nestedList1 = new ChoNestedList<int>(); nestedList1.Add(3); nestedList1.Add(new List<int>() { 4, 5 }); nestedList1.Add(6); nestedList1.Add(7); topList.Add(nestedList1); topList.Add(8); int count = 0; foreach (IList<int> list in topList.EnumerateAllChildLists()) { Console.WriteLine("List {0} contains".FormatString(count++)); foreach (int x in list) Console.WriteLine(x); } }
When you run the above code, the output will be
List 0 contains 3 4 5 6 7 List 1 contains 4 5 Press any key to continue . . .
