IList.IndexOf

Syntax

IndexOf(Value: Variant): Integer;

Parameters

Value. List element value that should be found.

Description

The IndexOf method searches for the specified value and returns the index in the list, if the search is successful.

Comments

The method returns -1 if the value is missing in the collection.

Example

Sub UserProc;
Var
    ArrayL: IArrayList;
    i: Integer;
Begin
    ArrayL := 
New ArrayList.Create;
    
For i := 0 To Math.RandBetweenI(0100Do
        ArrayL.Add(Math.RandBetweenI(
0100));
    
End For;
    i := ArrayL.IndexOf(
50);
End Sub UserProc;

After executing the example a dynamic array with random values is created, and the element with the 50 value is searched. In case of successful search, the "i" variable contains index of the found element.

See also:

IList