Home »
C#.Net »
C#.Net Q/A
Why is Dictionary preferred over Hashtable in C#?
Here, we are going to learn why is Dictionary preferred over Hashtable in C#.Net?
Submitted by Nidhi, on January 13, 2021
The Dictionary and Hashtable, both are collections in the .NET framework. The Dictionary is the generic collection, whereas Hashtable is a non-generic collection. It is very interesting that in the .Net framework Dictionary is implemented using Hashtable.
The Dictionary is preferred over HashTable because of type-safety and it maintains the order of stored values. We cannot insert the random object into the dictionary. Both Dictionary and Hashtable are used key/value pairs to store the data elements.