I want to have dictionary Dictionary<MyType,Something>
or hash set HashSet<MyType>
. In my application it holds that any two different instances of type MyType are never equal. Is it safe to use default implementation of GetHashCode and Equals in this case?
I am not sure how GetHashCode is implemented. But I always imagined that it is something like memory location of the object. Is this true?
If so then I would like to know what happens when garbage collector relocates the object? Can this happen? Could this cause that the object of MyType cannot be found in dictionary anymore?