Decimal.GetHashCode method is used to get the HashCode for the current Decimal instance.
Syntax: public override int GetHashCode ();
Return Value: This method returns a 32-bit signed integer hash code.
Below programs illustrate the use of the above discussed-method:
Example 1:
// C# program to illustrate the // Decimal.GetHashCode() Method using System; class GFG { // Main Method public static void Main() { // Taking decimal variables // having fractional part Decimal dec1 = 214748.78549M; // Getting the hash code for Decimal // using GetHashCode() method int result = dec1.GetHashCode(); // Display the time Console.WriteLine("HashCode for Decimal is: {0}", result); } } |
chevron_right
filter_none
Output:
HashCode for Decimal is: 161795526
Example 2:
// C# program to illustrate the // Decimal.GetHashCode() Method using System; class GFG { // Main Method public static void Main() { // using result() Method result(Decimal.MinValue); result(Decimal.MaxValue); } // result() method public static void result(decimal val) { // using GetHashCode() method int code = val.GetHashCode(); // Display the hashcode Console.WriteLine("HashCode for {0} is {1}", val, code); } } |
chevron_right
filter_none
Output:
HashCode for -79228162514264337593543950335 is -974127104 HashCode for 79228162514264337593543950335 is 1173356544
Reference:
Recommended Posts:
- Array.GetValue() Method in C# with Examples | Set - 1
- 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.GetHashCode() Method with Examples
- C# | Object.GetTypeCode() Method with Examples
- Graphics.Clear() Method in C# with Examples
- Type.GetConstructors() Method in C# with Examples
- List.FindIndex() Method in C# with Examples
- Double.Equals() Method in C# with Examples
- Decimal.GetTypeCode 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 contribute@geeksforgeeks.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.

