Click here to Skip to main content
11,704,768 members (59,091 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET ADO.NET
What is HashTable ? and what is the use of HashTable?
Posted 21-Oct-12 15:42pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hashtable optimizes lookups. It computes a hash of each key you add. It then uses this hash code to look up the element very quickly

you can check the detailed article here
http://www.dotnetobject.com/Thread-How-Hashtable-works-in-c[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 679
1 OriginalGriff 460
2 CPallini 242
3 Andy Lanng 235
4 F-ES Sitecore 160
0 OriginalGriff 8,864
1 Sergey Alexandrovich Kryukov 8,245
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100