tags:

views:

81

answers:

2

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

+6  A: 

According to Reflector:

public override int GetHashCode()
{
    return this;
}

Makes sense, does it?

Michael Stum
I suppose. I was thinking all value types would have a common implementation.
Esteban Araya
No, each Value type has it's own. UInt32 casts itself to Int32, this simply turning itself to a Signed Int. Int16 and Int64 do some funky bit shifting to generate a 32-Bit Value. System.Boolean returns 0 or 1 depending on it's state.
Michael Stum
A: 

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.

Daniel Mošmondor
Yes, but that doesn't necessarily mean it was implemented that way. :)
Esteban Araya