Boolean.GetHashCode() Method in C# with Examples
Last Updated :
23 Apr, 2019
Boolean.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 Boolean.GetHashCode() Method:
Example 1:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
bool value1 = true ;
int value = value1.GetHashCode();
Console.WriteLine( "HashCode is {0}" , value);
}
}
|
Example 2:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
get ( true );
get ( false );
}
public static void get ( bool value1)
{
int value = value1.GetHashCode();
Console.WriteLine( "HashCode is {0}" , value);
}
}
|
Output:
HashCode is 1
HashCode is 0
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...