Use IEqualityComparer <TKey> example in a common dictionary
Today, while researching a project, I was looking through documents for Dictionary<TKey, TValue>. There I found some remark that I might have forgotten in the past:
Since keys can be inherited and their behavior changed, their absolute uniqueness cannot be guaranteed by comparison using the Equals method.
The same remark, apparently, sprinkles over all the documents for most (turnkey) collection classes, which I examined later. But I could not find examples to illustrate the potential problem described, although I am pretty sure that this is what constructors accepting IEqualityComparer<TKey>for and arise when complex types are used as keys.
Can someone explain to me under what circumstances the problem that this comment points to may occur? Until I know exactly how and when such a problem can arise, I cannot solve it.