I have a lot of comparer classes where the class being compared is simply checking the name property of the object and doing a string compare. For example:
public class ExerciseSorter : IComparer<Exercise>
{
public int Compare(Exercise x, Exercise y)
{
return String.Compare(x.Name, y.Name);
}
}
public class CarSorter : IComparer<Car>
{
public int Compare(Car x, Car y)
{
return String.Compare(x.Name, y.Name);
}
}
what is the best way to have this code generic so i dont need to write redundant code over and over again.