Cinchoo – Collections, NestedDictionary, Part 1


.NET provides standard Dictionary<> collection class that represents strongly typed collection of key, value pairs. But lacks to store and access another Dictionary<> object as an item. Cinchoo provides this feature through ChoNestedDictionary<> collection class, where you can store another Dictionary<> or ChoNestedDictionary<> object as an item along with other strongly typed key-value pairs. It provides endless nested opportunity to store items. It exposes most of the Dictionary<> object members.

How to use

1. Add reference to Cinchoo.Core.dll assembly

2. Namespace Cinchoo.Core.Collections.Generic

Sample code,

static void Main(string[] args)
    ChoNestedDictionary outerDict = new ChoNestedDictionary();

    outerDict.Add(1, "outerDict-Tom");
    outerDict.Add(2, "outerDict-Mark");

    ChoNestedDictionary innerDict1 = new ChoNestedDictionary();
    innerDict1.Add(11, "innerDict1-Raj");
    innerDict1.Add(12, "innerDict1-Paul");

    Dictionary innerDict2 = new Dictionary();
    innerDict2.Add(21, "innerDict2-Mick");
    innerDict2.Add(22, "innerDict2-Donald");

    outerDict.Add(3, "Daniel");
    outerDict.Add(4, "Pamila");

    foreach (KeyValuePair keyValuePair in outerDict)
        Console.WriteLine(String.Format("Key: {0}, Value: {1}", keyValuePair.Key, keyValuePair.Value));

When you run the above code, the output will be

Key: 1, Value: outerDict-Tom
Key: 2, Value: outerDict-Mark
Key: 11, Value: innerDict1-Raj
Key: 12, Value: innerDict1-Paul
Key: 21, Value: innerDict2-Mick
Key: 22, Value: innerDict2-Donald
Key: 3, Value: Daniel
Key: 4, Value: Pamila
Press any key to continue . . .

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s