Esteban Araya
Esteban Araya

Reputation: 29664

How is GetHashCode() implemented for Int32?

I've been looking all over the place, but I can't find anything. Can anyone shed some light on this?

Upvotes: 47

Views: 19538

Answers (2)

Daniel Mošmondor
Daniel Mošmondor

Reputation: 19986

Best way to hash 32 bit value to 32 bit is not to invent wheel, use value itself. Very fast, no collisions, indeed a perfect way.

Upvotes: 3

Michael Stum
Michael Stum

Reputation: 181094

According to Reflector:

public override int GetHashCode()
{
    return this;
}

Makes sense, does it?

Upvotes: 79

Related Questions