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