Hello:
I find myself writing Comparison<Tdel egates that looks like this:
private static int compareCustomer s(Customer lhs, Customer rhs)
{
int result = Comparer<string >.Default.Compa re(lhs.LastName ,
rhs.LastName);
if (result == 0)
{
result = Comparer<string >.Default.Compa re(lhs.FirstNam e,
rhs.FirstName);
}
return result;
}
Is this pretty standard?
This approach is fine up to the point where you have to compare more
than two or three fields.
Does anyone have a more elegant method for writing complex
Comparison<T>'s ?
Thanks,
Travis
I find myself writing Comparison<Tdel egates that looks like this:
private static int compareCustomer s(Customer lhs, Customer rhs)
{
int result = Comparer<string >.Default.Compa re(lhs.LastName ,
rhs.LastName);
if (result == 0)
{
result = Comparer<string >.Default.Compa re(lhs.FirstNam e,
rhs.FirstName);
}
return result;
}
Is this pretty standard?
This approach is fine up to the point where you have to compare more
than two or three fields.
Does anyone have a more elegant method for writing complex
Comparison<T>'s ?
Thanks,
Travis
Comment