Difference between Dictionary and Hashtable in C#?

Asked 3 years ago
Viewed 730 times

0

Difference between Dictionary and Hashtable in C#?


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 data Dictionary is the generic collection, it can store data in key, value pair of a specific datatype
Hashtable is thread-safe The only member is thread-safe
return null if the key is not present in hashtable throw an exception if the key is not present
slower than Dictionary  faster than Hashtable 

answered 3 years ago by Ravi Vishwakarma

Your Answer