Single.GetHashCode() Method in C# with Examples
Single.GetHashCode() Method is used to return the hash code for this instance.
Syntax: public override int GetHashCode ();
Return Value: This method returns a 32-bit signed integer hash code.
Below programs illustrate the use of Single.GetHashCode() Method:
Example 1:
// C# program to demonstrate the // Single.GetHashCode() Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing value1 float value1 = 10f; // getting the HashCode // using GetHashCode() method int value = value1.GetHashCode(); // Display the HashCode Console.WriteLine("HashCode is {0}", value); } } |
chevron_right
filter_none
Output:
HashCode is 1092616192
Example 2:
// C# program to demonstrate the // Single.GetHashCode() Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(5f); get(9.5f); get(10000f); get(2327.5232f); } // defining get() method public static void get(float value1) { // getting the HashCode // using GetHashCode() method int value = value1.GetHashCode(); // Display the HashCode Console.WriteLine("HashCode is {0}", value); } } |
chevron_right
filter_none
Output:
HashCode is 1084227584 HashCode is 1092091904 HashCode is 1176256512 HashCode is 1158772831
Reference:
Recommended Posts:
- MathF.Exp() Method in C# with Examples
- MathF.Cos() Method in C# with Examples
- MathF.Pow() Method in C# with Examples
- MathF.Sin() Method in C# with Examples
- MathF.Min() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- MathF.Tan() Method in C# with Examples
- MathF.Log() Method in C# with Examples
- MathF.Max() Method in C# with Examples
- MathF.Truncate() Method in C# with Examples
- MathF.Acosh() Method in C# with Examples
- Double.Equals() Method in C# with Examples
- Double.CompareTo 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 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.



