on-internet
← Community

How is Object.GetHashCode() implemented in CLR & JVM?

Stack Overflow ·

I've been musing about this for some time: how exactly is Object.GetHashCode implemented in the CLR or Java? The contract for this method is that if it is called on the same object instance, it should always return the same value. Note that I'm talking about the default implementation of GetHashCode(). Derived classes are not required to override this method. If they choose not to do so, they will in essence have reference semantics: equality equals "pointer equality" by default when used in hash tables &c. This means that somehow, the runtime has to provide a constant hashcode for the object

Comments

Sign in or sign up to comment and upvote.

No comments yet.