In most programming languages, dictionaries are preferred over hashtables. What are the reasons behind that?
Dictionary
<<<>>> Hashtable
differences:
Synchronized()
methodKeyValuePair
<<<>>> Enumerated item: DictionaryEntry
Dictionary
/ Hashtable
similarities:
GetHashCode()
methodSimilar .NET collections (candidates to use instead of Dictionary and Hashtable):
ConcurrentDictionary
- thread safe (can be safely accessed from several threads concurrently)HybridDictionary
- optimized performance (for few items and also for many items)OrderedDictionary
- values can be accessed via int index (by order in which items were added)SortedDictionary
- items automatically sortedStringDictionary
- strongly typed and optimized for strings