Dictionary<TKey, TValue>在mscorlib.dll中浏览泛型类的实现时,我注意到以下用了很多次来获取哈希键:
int num = this.comparer.GetHashCode(key) & int.MaxValue;
Run Code Online (Sandbox Code Playgroud)
GetHashCode()返回一个int.我错误地认为int.MaxValue和任何整数x之间的按位AND 将始终返回x?
有人可以解释为什么以上述方式使用&运算符?
| 归档时间: |
|
| 查看次数: |
1547 次 |
| 最近记录: |