![]()
A 32-bit signed integer that is the hash code for this instance.
The ValueType.GetHashCode method applies to types derived from ValueType. One or more fields of the derived type is used to calculate the return value. If you call the derived type's GetHashCode method, the return value is not likely to be suitable for use as a key in a hash table. Additionally, if the value of one or more of those fields changes, the return value might become unsuitable for use as a key in a hash table. In either case, consider writing your own implementation of the ValueType.GetHashCode method that more closely represents the concept of a hash code for the type.
For more information, see object.GetHashCode, and Hashtable.
When you call the ValueType.GetHashCode method on a wrt structure, it provides the default behavior for value types that don’t override ValueType.GetHashCode. This is part of the support that the .NET Framework provides for the wrt (see .NET Framework Support for Windows Store Apps and Windows Runtime). wrt structures can’t override ValueType.GetHashCode, even if they’re written with C# or Visual Basic, because they can’t have methods. (In addition, structures in the wrt itself don’t inherit ValueType.) However, they appear to have ValueType.ToString, ValueType.Equals(object), and ValueType.GetHashCode methods when you use them in your C# or Visual Basic code, and the .NET Framework provides the default behavior for these methods.