Saturday 30 April 2011

IComparable and IComparer Interface in .NET

IComparable

The IComparable allows us to create a type-specific comparison method. If we implement the IComparable interface, we need to implement the IComparable’s member: CompareTo method. We usually compare if two instances of that class are equal using IComparable.

IComparer
The IComparer also allows us to create a type-specific comparison method. If we implement the IComparer interface, we need to implement the IComparer’s member: Compare method. We usually customize the sort order of a collection using IComparer.

No comments:

Post a Comment