Murali Poola
What is the difference between Dictionary and Hashtable ?
By Murali Poola in .NET on Apr 23 2012
  • Mahesh Kumar Alanka
    Jan, 2016 29

    Dictionary is a Generic Type where as HashTable is not Both Dictionary & HashTable holds the data like key, value as

    • 0
  • Anil Kumar Yadav
    Apr, 2012 30

    Dictionary and Hash table are collection of data structure to hold data as key-value pairs. Dictionary is generic type, hash table is not generic type. We can't use dictionary with web services. In .NET hash table is thread safe for use by multiple reader thread and a single writing thread, while in dictionary public static members are thread safe, but any instance members are not guaranteed to be thread safe.

    • 0
  • Lajapathy Arun
    Apr, 2012 28

    HashTable takes different datatypes as collection, but Dictionary allows only Specified datatype through out collection.

    • 0
  • Murali Poola
    Apr, 2012 23

    Dictionary is a generic type, allowing:
    static typing (and compile-time verification)
    use without boxing

    If you are .NET 2.0 or above, you should prefer Dictionary (and the other generic collections)

    A subtle but important difference is that Hashtable supports multiple reader threads with a single writer thread, while Dictionary offers no thread safety. If you need thread safety with a generic dictionary, you must implement your own synchronization or (in .NET 4.0) use ConcurrentDictionary.

    Dictionary is typed (so valuetypes don't need boxing), a Hashtable isn't (so valuetypes need boxing). 

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS