I use Dictionary in my code but my colleagues use Hashtable. MSDN says they work on Key Value pair &
examples of Hashtable and dictionary are same on MSDN.
Then how different are they from each other & which is the best of them or are they suited for difference occasions?
Hashtableis an untyped associative container that usesDictionaryEntryclass to return results of enumeration through its key-value pairs.Dictionary<K,T>is a generic replacement ofHashtablethat was introduced in C# 2.0. It usesKeyValuePair<K,T>generic objects to represent its key-value pairs.The only place where you should see
Hashtablethese days is legacy code that must run on .NET 1.1, before generics have been introduced. It’s been kept around for compatibility reasons, but you should preferDictionary<K,T>whenever you can.