- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between HashTable and Dictionary in C#
Both HashTable and Dictionary are the type of data structure which are used to store data. Both of these data structures hold the stored data in key value pair.
On the basis of difference between key features of these we can distinguish between HashTable and Dictionary as follows −
|1||Definition||HashTable is the non-generic type of collection which is used to store data in key/value pair and is defined in System.Collections name space.||On other hand Dictionary is a generic type collection defined under System.Collection.Generics name space which also store data in the form of key/value pairs.|
|2||DataType||In HashTable same or different data type data can be stored as key and value there is no restriction that key and value must of same DataType then only could get stored in the HashTable. Also there is no need to specify the type of the key and value.||On other hand in case of Dictionary key and value must be of same DataType then only could get stored in dictionary and must specify the type of key and value at the time of creation.|
|3||Data Retrieval||In case of HashTable the data retrieval is slower due to boxing and unBoxing as compared to that in Dictionary.||On other hand in case of Dictionary data Retrieval is faster as no boxing and unBoxing is take place in case of Dictionary.|
|4||Null Values||In case of HashTable null value handled as on access a key that doesn’t present in the given HashTable then null values returned as result.||On other hand, in case of Dictionary it will give error if try to access a key that doesn’t present in the given Dictionary.|
|5||Data Order||HashTable does not maintain any order of the inserted key value data.||On other hand Dictionary maintains the insertion order of stored value.|
- Difference between Dictionary and Hashtable in C#
- What is the difference between Dictionary and HashTable in PowerShell?
- Difference between HashTable and HashMap in Java
- Difference between HashMap and HashTable in Java.
- Difference between HashTable and ConcurrentHashMap in Java
- Working with Hashtable and Dictionary in C#
- Hashtable vs. Dictionary in C#
- Differences between HashMap and Hashtable in Java
- What is the difference between list and dictionary in C#?
- How to convert Dictionary to Hashtable in PowerShell?
- What is the difference between a python tuple and a dictionary?
- Why is a Dictionary preferred over a Hashtable in C#?
- What is the differences between HashMap and HashTable in Java
- Hashtable in Java