Possible Duplicate:
When to use IComparable<T> Vs. IComparer<T>
while IComparer works for both the cases.
Possible Duplicate:
When to use IComparable<T> Vs. IComparer<T>
while IComparer works for both the cases.
As the name suggests IComparable
is thing that can be compared and IComparar
is an object that can compare other objects. If you want to compare two objects of same type then you will implement IComparable
on it. If you want a type that can compare other objects then you will implement IComparer
.