System.Collections.IComparer
Added in .NET 1.1
When you implement the IComparer there are two steps.
Allows you to define and use multiple comparer checks (implemented outside the class)
First declare a class that implements IComparer
private class SortAscendingHelper : System.Collections.IComparer
{
int IComparer.Compare(object a, object b)
{
myobject = my1 (myObject)a;
myobject = my2 (myObject)b;
if (my1.MySortProperty > my2.MySortProperty)
{
return 1;
}
if (my1.MySortProperty < my2.MySortProperty)
{
return -1;
}
return 0;
}
}
Second implement the Compare method.
public static System.Collections.IComparer sortAscending()
{
return (IComparer) new SortAsecendingHelper();
}
System.Collections.Generic.IComparer<T>
Added in .NET 2.0
Provides additional comparison mechanisms
This allows you to provide ordering of your class on several fields or properties, ascending or descending order on the same field or both.
Allows you to define and use multiple comparer checks (implemented outside the class)
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext