In .net 4.0, this code will run correctly, but in 3.5 it will not. If I uncomment the individual ByID methods, the code works correctly. Is there a better way, or is that the best solution?
class Vehicle { public int ID {get; set;} public Vehicle() { } public Vehicle(int id) { this.ID = id; }
public static Predicate<Vehicle> ByID(int id) { return delegate(Vehicle vehicle) { return vehicle.ID == id; }; }
}
class Auto : Vehicle { public Auto(int id) { this.ID = id; }
//public new static Predicate<Auto> ByID(int id) //{ // return delegate(Auto auto) // { // return auto.ID == id; // }; //}
}
class Plane : Vehicle { public Plane(int id) { this.ID = id; }
//public new static Predicate<Plane> ByID(int id) //{ // return delegate(Plane plane) // { // return plane.ID == id; // }; //}
}
|