Difference between Dictionary and Hashtable in C#?

Asked 27-Aug-2021
Viewed 645 times

1 Answer


0

Difference between Hashtable and Dictionary

Hashtable Dictionary
Hashtable is present in System.Collections namespace.Dictionary is present in System.Collections.Generic namespace
Hashtable is the non-generic collection, it can store data in key, the value of any type of dataDictionary is the generic collection, it can store data in key, value pair of a specific datatype
Hashtable is thread-safeThe only member is thread-safe
return null if the key is not present in hashtablethrow an exception if the key is not present
slower than Dictionary faster than Hashtable