IComparer.Compare

Syntax

Compare(x: Variant; y: Variant): Integer;

Parameters

x. Object that should be compared.

y. Object, with which it is required to compare.

Description

The Compare method compares objects passed as input parameters and returns comparison result.

Comments

The method returns the following values:

If the Compare method is redetermined in the application class, the method can return any values.

Example

Add a link to the Math system assembly.

Sub UserProc;
Var
    Comp: IComparer;
    x, y: DateTime;
    i, Year, Month, Day: Integer;
Begin
    Day := Math.RandBetweenI(131);
    Month := Math.RandBetweenI(112);
    Year := Math.RandBetweenI(20002020);
    x := DateTime.Today;
    y := DateTime.ComposeDay(Year, Month, Day);
    Comp := Comparer.DateTimeComparer;
    i := Comp.Compare(x, y);
End Sub UserProc;

After executing the example the "i" variable contains the result of comparison of the current date and the other one generated in random way.

See also:

IComparer