Share via


Object.GetHashCode Method

Serves as a hash function for a particular type.

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

Syntax

[MethodImplAttribute]
public virtual int GetHashCode ()

Return Value

A hash code for the current object.

Remarks

You can use the GetHashCode method to hash algorithms and data structures (such as hash tables).

The GetHashCode method can be overridden by a derived class. Value classes must override this method to provide a hash function that is appropriate for the class and that ensures optimum distribution in the hash table. Classes that might be used as keys in a hash table must also override this method, because objects that are used as keys in a hash table are required to generate their own hash code by using this method.

Version Information

Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, 4.1, and 4.2.

See Also

Reference

Object Class
Object Members
System Namespace