Possible Duplicate:
Why Dictionary is preferred over hashtable in C#?
Hi, I noticed that we have both a hashtable implementation and a dictionary implementation in C#. but, isn't a hashtable a way of implementing a dictionary. Then, why provide both? Dont they do the same thing.
Already answered here on StackOverFlow
The best answer was from Michael Madsen : Dictionary is a generic type, Hashtable is not. That means you get type safety with Dictionary, because you can't insert any random object into it, and you don't have to cast the values you take out.
Dictionary is a Generic Type , Hashtable is not
Type Conversion
1- Hashtable is a non generic key value collection and requires run time type conversion.
2- Dictionary is a generic key value collection and does not require run time type conversion.
Collision Avoidence
1- Hashtable uses Double Hashing to Collisions avoidance technique.
2- Dictionary uses Chaining for avoidence.
See Here At MSDN
精彩评论