IObject: GetHashCode |
Serves as a hash function for a particular type.
Public Function GetHashCode ( ) As Long
A hash code is a numeric value that is used to identify an object during equality testing. It can also serve as an index for an object in a collection.
The GetHashCode method is suitable for use in hashing algorithms and data structures such as a hash table.
The default implementation of the GetHashCode method does not guarantee unique return values for different values. Furthermore, VBCorLib does not guarantee the default implementation of the GetHashCode method, and the value it returns will be the same between different versions of VBCorLib. Consequently, the default implementation of this method must not be used as a unique object identifier for hashing purposes.
Implementations of the GetHashCode method must not result in circular references. For example, if ClassA.GetHashCode calls ClassB.GetHashCode, ClassB.GetHashCode must not call ClassA.GetHashCode either directly or indirectly.
Implementations of the GetHashCode method must not throw exceptions.
The following code demonstrates an implementation of the GetHashCode method. This does not show the complete implementation of the IObject interface.
Implements IObject Public X As Long Public Y As Long Public Function GetHashCode() As Long GetHashCode = X Xor Y End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' IObject ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Function IObject_GetHashCode() As Long IObject_GetHashCode = GetHashCode End Function