IStringList.IndexOf

Syntax

IndexOf(Value: String): Integer;

Parameters

Value. Value that should be found.

Description

The IndexOf method executes direct search of value and returns element index in case of successful search, otherwise it returns -1.

Example

Sub Main;

Var

StrL: IStringList;

i: Integer;

Begin

StrL:=New StringList.Create;

For i:=0 To Math.RandBetweenI(50,100) Do

StrL.Add("Number "+Math.RandBetweenI(0,100).ToString);

End For;

i:=StrL.IndexOf("Number 25");

End Sub Main;

After executing the example a dynamic array of strings is generated, the element with the Number 25 value is searched, and in case of successful search the "i" variable contains index of this element.

See also:

IStringList