Quantcast
Channel: Cinchoo » type-safe
Viewing all articles
Browse latest Browse all 10

Cinchoo – Collections, NestedList, Part 5

$
0
0

GetListItemAt

ChoNestedList<T> provides one another helper method to get the underlying list object at a specified index

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(4);
    nestedList1.Add(5);
    topList.Add(nestedList1);

    topList.Add(6);

    Console.WriteLine("Underlying list object at index 3 is");
    foreach (int x in topList.GetListItemAt(3))
        Console.WriteLine(x);

    Console.WriteLine("Underlying list object at index 5 is");
    foreach (int x in topList.GetListItemAt(5))
        Console.WriteLine(x);
}

When you run the above code, the output will be

Underlying list object at index 3 contains
3
4
5
Underlying list object at index 5 contains
1
2
3
4
5
6
Press any key to continue . . .


Viewing all articles
Browse latest Browse all 10

Trending Articles