Not a direct answer to your question, which Jonas has answered well, however this may be of assistance if you are worried about equality testing in hashes
From our tests, depending on what you are requiring with hashcodes, in C#, hashcodes do not need to be unique for Equality operations. As an example, consider the following:
We had a requirement to overload the equals operator, and therefore the GetHashCode function of our objects as they had become volatile and stateless, and sourcing themselves directly from data, so in one place of the application we needed to ensure that an object would be viewed as equal to another object if it was sourced from the same data, not just if it was the same reference. Our unique data identifiers are Guids.
The equals operator was easy to cater for as we just checked on the Guid of the record (after checking for null).
Unfortuantely the HashCode data size (being an int) depends on the operating system, and on our 32 bit system, the hashcode would be 32 bit. Mathematically, when we override the GetHashCode function, it is impossible to generate a unique hashcode from a guid which is greater than 32 bit (look at it from the converse, how would you translate a 32 bit integer into a guid?).
We then did some tests where we took the Guid as a string and returned the HashCode of the Guid, which almost always returns a unique identifier in our tests, but not always.
What we did notice however, when an object is in a hashed collection object (a hashtable, a dictionary etc), when 2 objects are not unique but their hashcodes are, the hashcode is only used as a first option lookup, if there are non-unique hash codes being used, the equality operator is always used as a fall back to detirmine equality.
As I said this may or may not be relevant to your situation, but if it is it's a handy tip.
UPDATE
To demonstrate, we have a Hashtable:
Key:Object A (Hashcode 1), value Object A1
Key:Object B (Hashcode 1), value Object B1
Key:Object C (Hashcode 1), value Object C1
Key:Object D (Hashcode 2), value Object D1
Key:Object E (Hashcode 3), value Object E1
When I call the hashtable for the object with the key of Object A, the object A1 will be returned after 2 steps, a call for hashcode 1, then an equality check on the key object as there is not a unique key with the hashcode 1
When I call the hashtable for the object with the key of Object D, the object D1 will be returned after 1 step, a hash lookup
GetHashCode()
. Use it only for its intended purpose: to facilitate the use of hash tables. – Disaccord