Difference between Hashtable and Dictionary in C#
In C#, Dictionary is a generic collection which is generally used to store key/value pairs. Dictionary is defined under System.Collection.Genericsnamespace. It is dynamic in nature means the size of the dictionary is growing according to the need.
A Hashtable is a collection of key/value pairs that are arranged based on the hash code of the key. Or in other words, a Hashtable is used to create a collection which uses a hash table for storage. It is the non-generic type of collection which is defined in System.Collectionsnamespace. In Hashtable, key objects must be immutable as long as they are used as keys in the Hashtable.
A Hashtable is a collection of key/value pairs that are arranged based on the hash code of the key. Or in other words, a Hashtable is used to create a collection which uses a hash table for storage. It is the non-generic type of collection which is defined in System.Collectionsnamespace. In Hashtable, key objects must be immutable as long as they are used as keys in the Hashtable.
Example:
|
Example
|
Comments
Post a Comment