Dictionary implementation of ListDictionary, HybridDictionary, and OrderedDictionary

Hastable is very good implementation of dictionary but it has a little bit overhead then it comes to performance. As a result, simpler Dictionaries were implemented for smaller lookup tables one of them is ListDictionary that has array under the hood.

ListDictionary myEmailLookup = new ListDictionary ();

myEmailLookup["sbishop@contoso.com"] = "Bishop, Scott";
myEmailLookup["chess@contoso.com"] = "Hess, Christian";
myEmailLookup["djump@contoso.com"] = "Jump, Dan";
foreach (DictionaryEntry entry in myEmailLookup)

This is very similar to has in a way its being implemented as we can see.

ListDictionary is good if you know that you are dealing with small list. What if size is unknown then you will use HybridDictionary which starts as ListDictionary and then list grows in size converts itself into Hashtable
HybridDictionary myEmail = new HybridDictionary ();
myEmail["sbishop@contoso.com"] = "Jame, Gath";
myEmail["chess@contoso.com"] = "Todd, Sims";
myEmail["djump@contoso.com"] = "Garry, Trap";
foreach (DictionaryEntry entry in myEmail)

If you really need an ordered Hashtable then you should switch to OrderedDictionary which possesses following Properties and Methods.



Item Overloaded to support access by index



Insert Inserts a key/value pair at a specific index in the collection
RemoveAt Removes a key/value pair at a specific index in the collection