As Date says it implements the IComparable interface, it needs to provide a CompareTo method:
public int CompareTo(object pObject)
{
Date tDate = (Date)pObject;
int tResult = iYear - tDate.iYear;
if (tResult==0)
{
tResult = iMonth - tDate.iMonth;
if (tResult==0)
{
tResult = iDay - tDate.iDay;
}
}
return tResult;
}
Gunnerson (3, p249) says ‘If a class has an ordering that is expressed in IComparable, it may also make sense to overload the other relational operators. As with == and !=, other operators must be declared as pairs, with < and > being one pair, and >= and <= being the other pair.’