I\'m trying to figure out which of these interfaces I need to implement. They both essentially do the same thing. When would I use one over the other?
Simple Explanation via a story
High school basketball. It's a school yard pick for the teams. I want to get the tallest/best/fastest folks on my team. What do I do?
IComparer Interface - Compare two people separate people
Compare(Fred, John) and it spits out who's better. What about IComparable? - Compare yourself with someone else
Have you been on FB recently? You see other folks doing cool things: travelling the world, creating inventions, while I'm doing something not quite as cool - well what we are doing is making use of the IComparable interface.
What about the Comparer Class?
The Comparer class is an abstract base class which implements the IComparer interface. You should derive from this class to have a concrete implementation. anyways, Microsoft recommends that you DO use the Comparer class rather than implement the IComparer interface:
We recommend that you derive from the Comparer class instead of implementing the IComparer interface, because the Comparer class provides an explicit interface implementation of the IComparer.Compare method and the Default property that gets the default comparer for the object.
Hope the stories help you remember.