Quoted from http://bytes.com/topic/c-sharp/answers/230884-icomparable-vs-icomparer
Any class that implements IComparable is *comparable*. That is, you can
compare an instance of that class with another instance in a manner that
you define.
OTOH, a class that implements IComparer is a... well, a comparer (Java
people call this a Comparator), i.e.: a class that imposes ordering on a
set of objects.
When you want to sort an unsorted array of objects of the same class,
you can either make the class implement IComparable, or you can
implement IComparer in a separate class, and pass that to Array.Sort().
Of course if the comparison is done based on a *private* member of the
class, IComparable is more appropriate, since having your IComparator
implementation be able to access its private members may not be
possible/appropriate.
Any class that implements IComparable is *comparable*. That is, you can
compare an instance of that class with another instance in a manner that
you define.
OTOH, a class that implements IComparer is a... well, a comparer (Java
people call this a Comparator), i.e.: a class that imposes ordering on a
set of objects.
When you want to sort an unsorted array of objects of the same class,
you can either make the class implement IComparable, or you can
implement IComparer in a separate class, and pass that to Array.Sort().
Of course if the comparison is done based on a *private* member of the
class, IComparable is more appropriate, since having your IComparator
implementation be able to access its private members may not be
possible/appropriate.