What purpose does the Comparer
class serve if the type that you specify already implements IComparable
?
If I specify Comparer.Defaul
There are a few subtle points here:
IComparable
- it also supports the older (non-generic) IComparable
as a fallback. This means that it can't be expressed just as (for example) a generic constraintNullable
where T
is comparable, even though Nullable
clearly isn't IComparable
or IComparable
List
can provide a Sort
even though it doesn't insist that all T
are sortable; you'd be amazed how quickly the generic constraints would otherwise accumulate