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

I want my Food class to be able to test whenever it is equal to another instance of Food. I will later use it against a List, and I want to use its List.Contains() method. Should I implement IEquatable<Food> 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?

4 Answers
4

Leave a Comment