While browsing the implementation of the generic Dictionary<TKey, TValue>
class in mscorlib.dll, I noticed the following used many times to get a hash-key:
int num = this.comparer.GetHashCode(key) & int.MaxValue;
GetHashCode() returns an int. Am I mistaken in thinking that a bitwise AND between int.MaxValue and any integer x, will always return x?
Can someone explain why the & operator is used in the manner above?