What's the difference between IEquatable and just overriding Object.Equals() ?

Posted by devoured elysium on Stack Overflow See other posts from Stack Overflow or by devoured elysium
Published on 2010-04-29T05:12:40Z Indexed on 2010/04/29 5:17 UTC
Read the original article Hit count: 372

Filed under:
|
|
|
|

I want my Food class to be able to test whenever it is equal to another class. I will later use it against a List, and I want to use its List.Contains() method. Should I implement IEquatable or just override Object.Equals()? From MSDN:

This method determines equality by using the default equality comparer, as defined by the object's implementation of the IEquatable.Equals method for T (the type of values in the list).

So my next question is: which functions/classes of the .NET framework make use of Object.Equals()? Should I use it in the first place?

Thanks

© Stack Overflow or respective owner

Related posts about equals

Related posts about equality