Comparer

Comparer


Provides a default mechanism to compare two values. The values must be of the same datatype to be compared. Otherwise an exception will be thrown.


Remarks

The default comparer requires that the two datatypes being compared be the same. This includes comparing two numbers such that comparing a vbLong type to a vbInteger type will result in an exception.
Strings will not be converted to numbers for comparison, even though VB supports this action. The comparisons of strings is case-sensitive. For case-insensitive comparisons, use an instance of CaseInsensitiveComparer class.

In order for objects to be accepted in the comparison, they must implement the IComparable interface. The comparer will then call the object through the IComparable.Compare method, passing in the value for the object to compare itself with.

The return value should indicate the objects relation to the value passed in:
Positive number = object > value
Negative number = object < value
Return of zero = object = value

See Also

Project VBCorLib Overview | ComparerStatic

Implements:

IComparer 

Public:

Methods:

NameDescription
 CompareReturns the comparison between to values.