- 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
Why is a Dictionary preferred over a Hashtable in C#?
Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection.
Dictionary is a collection of keys and values in C#. Dictionary<TKey, TValue> is included in the System.Collection.Generics namespace.
Hashtable is slower than Dictionary. For strongly-typed collections, the Dictionary collection is faster.
Let’s say we need to find a key from Hashtable collections. With that, we are also finding a key from Dictionary collection as well. In that case, Dictionary would be faster for the same statement −
- Why is IPv6 preferred over IPv4?
- Why is char preferred over String for storing passwords?
- Why is gold jewellery more preferred over silver jewellery?
- What is Java Server Pages, JSP? Why JSP is preferred over CGI?
- Why is cow milk preferred over Buffalo milk by most fitness freaks?
- Hashtable vs. Dictionary in C#
- How to iterate over a C# dictionary?
- Iterate over a dictionary in Python
- Working with Hashtable and Dictionary in C#
- Difference between Dictionary and Hashtable in C#
- Difference between HashTable and Dictionary in C#
- What is the best way to iterate over a Dictionary in C#?
- Check if a Hashtable is equal to another Hashtable in C#
- When can a double-type be preferred over float-type in Java?
- Clear a Hashtable in C#