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
Is it possible that you copied this string from somewhere?
I had the same problem. I copied the value ans somehow the BOM header is invisible on the first position.
Try checking the length and you see already a difference. Also you could check byte-by-byte.
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.