Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is HashTable ? and what is the use of HashTable?
Posted

The uses of Hashtable is related to the fact that it supports lookup of an element of collection by some key with the computational complexity of O(1); that is, the time of search asymptotically does not grow with growing the size of the collection but remains approximately the same on average, with big collections.

Please see:
http://en.wikipedia.org/wiki/Big_O_notation[^],
http://en.wikipedia.org/wiki/Computational_complexity_theory[^].

Also, the type support uniqueness of the key in the scope of collection.

The problem with this type in .NET is that its is the obsolete because it is not generic, which required potentially error-prone type casts. There is no reason to ever use it in any new development, because generics were introduced in .NET Framework v.2.0, and using earlier .NET version hardly makes any sense. This type was not formally marked with [Obsolete] attribute just because there is nothing wrong with keeping it in existing and well working legacy code.

In any new development, you should to use any of the three generic types instead of HashTable:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx[^],
http://msdn.microsoft.com/en-us/library/f7fta44c.aspx[^],
http://msdn.microsoft.com/en-us/library/ms132319.aspx[^].

These classes are different majorly by different trade-off between performance and redundancy.

—SA
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900