Hashtable optimizes lookups. It computes a hash of each key you add. It then uses this hash code to look up the element very quickly. It is an older .NET Framework type. It is slower than the generic type.
A dictionary is used where fast lookups are critical. The type provides fast lookups with keys to get values. With it we use keys and values of any type, including s and s. Dictionary requires a special syntax form.
Dictionary is used when we have many different elements. We specify its key type and its value type. It provides good performance.
Differences between Hashtable and Dictionary
1) It returns error if we try to find a key which does not exist.
2) It is faster than a Hashtable because there is no boxing and unboxing.
3) Only public static members are thread safe.
4) Dictionary is a generic type which means we can use it with any data type.
1) It returns null if we try to find a key which does not exist.
2) It is slower than dictionary because it requires boxing and unboxing.
3) All the members in a Hashtable are thread safe.
4) Hashtable is not a generic type.