How to generate unique integer from string?
Be wary of string.GetHashCode()
.
The .Net documentation states https://msdn.microsoft.com/en-us/library/system.string.gethashcode(v=vs.110).aspx
The hash code itself is not guaranteed to be stable. Hash codes for identical strings states can differ across versions of the.NET Framework and across platforms (such as 32-bit and 64-bit) for a single version of the .NET Framework. In some cases, they can even differ by application domain
Just take string.GetHashCode()
which returns an int
from a string
with very low collision probability.