This method is used to return the hash code for this instance. A hash code is a numeric value which is used to insert and identify an object in a hash-based collection. The
GetHashCode method provides this hash code for algorithms that need quick checks of object equality.
public virtual int GetHashCode ();
Return Value: This method returns a 32-bit signed integer hash code for the current object.
Below programs illustrate the use of Object.GetHashCode() Method:
Type is :System.Object Hash Code is :37162120
Author details: first Name : Kirti last Name : Mangal The hash code of object is: -751588944
- Two objects that return different hash codes means objects are not equal but the reverse is not true. Means, equal hash codes do not imply object equality, because different (unequal) objects can have identical hash codes.
- The .NET Framework does not guarantee the default implementation of the GetHashCode method, and the value this method returns may differ between .NET Framework versions and platforms, such as 32-bit and 64-bit platforms.
- A hash code is not a permanent value so do not serialize, store the hash values in databases etc.
- Do not test for equality of hash codes to determine whether two objects are equal.
- Array.GetValue() Method in C# with Examples | Set - 1
- File.GetLastWriteTimeUtc() Method in C# with Examples
- MathF.Sin() Method in C# with Examples
- Double.CompareTo Method in C# with Examples
- UInt16.GetHashCode Method in C# with Examples
- Int64.CompareTo Method in C# with Examples
- MathF.Truncate() Method in C# with Examples
- MathF.Exp() Method in C# with Examples
- C# | Queue<T>.TrimExcess Method with Examples
- C# | Stack<T>.TrimExcess Method with Examples
- Array.BinarySearch(Array, Object) Method with examples in C#
- C# | Char.GetHashCode() Method with Examples
- C# | Char.GetTypeCode() Method with Examples
- C# | Char.GetUnicodeCategory(String, Int32) Method with Examples
- C# | Object.GetTypeCode() Method with Examples
- Array.BinarySearch(Array, Int32, Int32, Object) Method with examples in C#
- Stack.ToString() Method in C# with examples
- Graphics.Clear() Method in C# with Examples
- Type.GetConstructors() Method in C# with Examples
- List.FindIndex() Method in C# with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : jenafrank