Array.LastIndexOf

Syntax

LastIndexOf(Value: Variant): Integer;

Parameters

Value - value that should be found in the array.

Description

The LastIndexOf method searches for the value passed as the Value input parameter in the array and returns the index of the last occurrence of the corresponding element. If the value is not found, the method returns -1.

NOTE. This method is supported for one-dimensional arrays only.

Example

Sub Main;

Var

Ar: Array[0..20] Of Integer;

i, j: Integer;

Begin

For i := 0 To 20 Do

Ar[i] := Math.RandBetweenI(0, 50);

End For;

j := Ar.LastIndexOf(10);

End Sub Main;

After executing the example random data is written to the Ar one-dimensional array, the "j" variable will contain the index of the last value 10 found in the array.

See also:

Array