IEqualityComparer.GetHashCode Method (Object)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns a hash code for the specified object.

Namespace:   System.Collections
Assembly:  mscorlib (in mscorlib.dll)

abstract GetHashCode : 
        obj:Object -> int

Parameters

obj
Type: System.Object

The Object for which a hash code is to be returned.

Return Value

Type: System.Int32

A hash code for the specified object.

Exception Condition
ArgumentNullException

The type of obj is a reference type and obj is null.

Implement this method to provide customized hash codes for objects,corresponding to the customized equality comparison provided by the Equals method.

Notes to Implementers:

Implementations are required to ensure that if the Equals method returns true for two objects x and y, then the value returned by the GetHashCode method for x must equal the value returned for y.

The following code example demonstrates the implementation of a case-insensitive IEqualityComparer. In this example, the GetHashCode method returns the hash code provided by the Object type.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: