String.GetHashCode() returns different values

前端 未结 2 799
甜味超标
甜味超标 2021-02-12 06:02

Why is GetHashCode() returning a different value for the same string? I can\'t describe how to duplicate this, but trust that this is not a practical joke and that the two follo

2条回答
  •  不要未来只要你来
    2021-02-12 06:48

    According to documentation:

    If two string objects are equal, the GetHashCode method returns identical values. However, there is not a unique hash code value for each unique string value. Different strings can return the same hash code.

    Thus, some other effect must be in play for the two calls to give different results. One theory is that you switched platforms between the calls, from x86 to x64 or vice versa.

提交回复
热议问题