I want to be able to get a uniqe hash from all objects. What more,
in case of
Dictionary<string, MyObject> foo
I want the unique keys for:
- string
- MyObject
- Properties in MyObject
- foo[someKey]
- foo
etc..
object.GetHashCode() does not guarantee unique return values for different objects.
That’s what I need.
Any idea? Thank you
Simply put this is not possible. The GetHashCode function returns a signed integer which contains 2^32 possible unique values. On a 64 bit platform you can have many more than 2^32 different objects running around and hence they cannot all have unique hash codes.
The only way to approach this is to create a different hashing function which returns a type with the capacity greater than or equal to the number of values that could be created in the running system.