C# StringComparer GetHashCode(String)

Description

StringComparer GetHashCode(String) when overridden in a derived class, gets the hash code for the specified string.

Syntax

StringComparer.GetHashCode(String) has the following syntax.


public abstract int GetHashCode(
  string obj
)

Parameters

StringComparer.GetHashCode(String) has the following parameters.

  • obj - A string.

Returns

StringComparer.GetHashCode(String) method returns A 32-bit signed hash code calculated from the value of the obj parameter.

Example


using System;//  w ww.jav a2 s  . c o m

class Sample 
{
    public static void Main() 
    {
        StringComparer invCmp =   StringComparer.Ordinal;
        
        Console.WriteLine(invCmp.GetHashCode("asdf"));
    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version