J
jehugaleahsa
Hello:
I find myself writing Comparison<T> delegates that looks like this:
private static int compareCustomers(Customer lhs, Customer rhs)
{
int result = Comparer<string>.Default.Compare(lhs.LastName,
rhs.LastName);
if (result == 0)
{
result = Comparer<string>.Default.Compare(lhs.FirstName,
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<T> delegates that looks like this:
private static int compareCustomers(Customer lhs, Customer rhs)
{
int result = Comparer<string>.Default.Compare(lhs.LastName,
rhs.LastName);
if (result == 0)
{
result = Comparer<string>.Default.Compare(lhs.FirstName,
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