Wednesday 2 August 2017

Dictionary vs Hashtable in c#



  • Dictionary
o    It returns error if we try to find a key which does not exist.
o    It is faster than a Hashtable because there is no boxing and unboxing.
o    Only public static members are thread safe.
o    Dictionary is a generic type which means we can use it with any data type.

  • Hashtable

o    It returns null if we try to find a key which does not exist.
o    It is slower than dictionary because it requires boxing and unboxing.
o    All the members in a Hashtable are thread safe,
o    Hashtable is not a generic type.

No comments:

Post a Comment