Click here to Skip to main content
15,882,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi could you tell me what does it mean and what does the last line return:
ArrayList p = new ArrayList;<br />

From MSDN:

A hash code is a numeric value that is used to identify an object during equality testing. It can also serve as an index for an object in a collection.

The GetHashCode method is suitable for use in hashing algorithms and data structures such as a hash table.

I think that about sums it up!
Share this answer
First, there is not need to use ArrayList since it was rendered obsolete by introducing of generics in .NET Framework 2.0. Use System.Collections.Generic.List. Now, object.GetHashCode is really needed to store data elements in hash-based containers: System.Generic.Collections.Dictionary, System.Generic.Collections.SortedDictionary, System.Generic.Collections.SortedList. The hash code for the Key type is important and should be written the way to provide "good" hashing properties helping to optimize the search speed in the collection.

The mechanism of such search and data structure is based on backets, which is explained here:[^].

Share this answer
Abhinav S 23-Jul-11 0:10am    
MY 5.
Sergey Alexandrovich Kryukov 23-Jul-11 0:19am    
Thank you, Abhinav.
Some good information on the GetHashCode() method at a blog[^] and on the msdn link[^].
Share this answer
Sergey Alexandrovich Kryukov 23-Jul-11 0:20am    
Good to read, too, my 5.
Abhinav S 23-Jul-11 0:21am    
Thank you SA.

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