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); }
//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."); }
public int CompareTo(Vehicle other) { return(Make.CompareTo(other.Make)); }