Base of Difference | Dictionary | Hashtable |
Type | Dictionary is basically a generic type Dictionary <TKey,TValue> | Hashtable is basically a non-generic type. |
Boxing and Unboxing | In Dictionary we donot have need of boxing and unboxing. | Values in hashtable need both boxing and unboxing. |
Weak Strong | Dictionary class is strong type so you must specify the data types for key and value (<TKey,TValue>). | Hashtable is basically a weak type data structure so we can add keys and values of any of object type. |
Non-Existing key | In Dictionary when we try to access non existing key dictionary we will get runtime error. | But when we try to access non existing key hashtable it will produce null values. |
Order of Values | Dictionary maintains an order of stored values. | On the other hand Hashtable never maintains an order of stored values. |
Speed | As there is no need of boxing and unboxing it is faster than hashtable.
| Hashtable needs boxing and unboxing so it is slower tahn Dictionary. |