string.GetHashCode() returns different values in debug vs release, how do I avoid this?
问题 To my surprise the folowing method produces a different result in debug vs release: int result = "test".GetHashCode(); Is there any way to avoid this? I need a reliable way to hash a string and I need the value to be consistent in debug and release mode. I would like to avoid writing my own hashing function if possible. Why does this happen? FYI, reflector gives me: [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), SecuritySafeCritical] public override unsafe int GetHashCode