是否可以确保.GetHashCode在系统/平台版本之间相同? [英] Is .GetHashCode guaranteed to be the same across systems/platform versions?
问题描述
Possible Duplicate:
Can I depend on the values of GetHashCode() to be consistent?
如果我在两个系统/框架版本之间使用Object.GetHashCode()
方法,是否可以确保为相同的输入获得相同的值?换句话说,它的值是否成为持久数据的好钥匙?
If I use the Object.GetHashCode()
method across two systems/framework versions, am I guaranteed to get the same value for the same input? In other words, does its value make a good key for persistent data?
注意:我不在乎这个问题中的冲突.
Note: I don't care about collisions in this problem.
作为奖励,我是否可以保证在Mono与Microsoft .Net中获得相同的价值?
As a bonus, am I guaranteed to get the same value in Mono vs. Microsoft .Net?
推荐答案
否.还有其他问题吗? :-)
No. Other questions? :-)
所使用的算法尚未发布,也不在Ecma标准中.
The algorithms used aren't published nor they are in the Ecma standard.
我将引用MSDN String.GetHashCode (我认为这个例子足够好)
I'll quote from the MSDN String.GetHashCode (I think that this example is good enough)
GetHashCode的行为取决于其实现,它可能从公共语言运行时的一种版本更改为另一种版本.发生这种情况的原因是为了提高GetHashCode的性能.
The behavior of GetHashCode is dependent on its implementation, which might change from one version of the common language runtime to another. A reason why this might happen is to improve the performance of GetHashCode.
这篇关于是否可以确保.GetHashCode在系统/平台版本之间相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!