IndexOf(Value: Variant): Integer;
Value. List element value that should be found.
The IndexOf method searches for the specified value and returns the index in the list, if the search is successful.
The method returns -1 if the value is missing in the collection.
Sub UserProc;
Var
ArrayL: IArrayList;
i: Integer;
Begin
ArrayL := New ArrayList.Create;
For i := 0 To Math.RandBetweenI(0, 100) Do
ArrayL.Add(Math.RandBetweenI(0, 100));
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: