2

Possible Duplicate:
When to use a HashTable

Why we use Hashtable in csharp? What is the need of it?

Community
  • 1
  • 1
Dhruv
  • 21
  • 1
  • 4
    [Wikipedia](http://en.wikipedia.org/wiki/Hashtable): *In many situations, hash tables turn out to be more efficient than search trees or any other table lookup structure. For this reason, they are widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.* – Felix Kling Mar 13 '11 at 15:51

3 Answers3

2

Probably you don't want to use the HashTable (non generic) at all, but rather use the

Dictionary<TKey, TValue>

or the

HashSet<T>

if you only need keys

Pleun
  • 8,856
  • 2
  • 30
  • 50
  • 1
    Beep... Why? At least you should have suggested the Dictionary as a (nearly always) better substitute for the Hashtable. The HashSet is something different (but connected to) – xanatos Mar 13 '11 at 20:14
1

When to use a HashTable

Community
  • 1
  • 1
joelt
  • 2,672
  • 2
  • 24
  • 32
0

One easy answer would be "performance" using hashtables to store data makes it possible to find and access the data much faster than iteraing over all objects in a list. Wikipedia has a great (large) article about hash tables in general, which gives a good description about it.

aweis
  • 5,350
  • 4
  • 30
  • 46