I asked a question here : When To Use IEquatable And Why about using IEquatable.
From the msdn:
The IEquatable(T) interface is used by generic collection objects such as Dictionary(TKey, TValue), List(T), and LinkedList(T) when testing for equality in such methods as Contains, IndexOf, LastIndexOf, and Remove.
If you dont implement that interface what exactly happens?? Exception / default object equals / ref equals?
If you don't implement equality comparison, the default implementation will be used.
If the key is a reference type, reference comparision is used. Unless you keep the key objects so that you can use them when retrieving items from the collection, they are lost. Creating a new key object from the same data gives you an object with a difference reference, so it will miss the item you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With