Example #1
0
 public int CompareTo(Vehicle other)
 {
     return((VehicleType == other.VehicleType &&
             Make.CompareTo(other.Make) == 0 &&
             Model.CompareTo(other.Model) == 0 &&
             ProductionYear == other.ProductionYear &&
             LicensePlate.CompareTo(other.LicensePlate) == 0) ?  0 : -1);
 }
Example #2
0
 //Step 2: Implement the IComparable interface
 public int CompareTo(object obj)
 {
     if (obj is Car)
     {
         Car c2 = (Car)obj;
         return Make.CompareTo(c2.Make);
     }
     else
         throw new ArgumentException("Object is not of type Car.");
 }
Example #3
0
 public int CompareTo(Vehicle other)
 {
     return(Make.CompareTo(other.Make));
 }