TSubstringList.IndexOf Method

function IndexOf(const S: string): Integer; overload;

The index of the first item equal to S, or -1.

#NameDescription
1S

The text, every text kind.

Returns: Integer - The item's index, or -1.

Remarks:

As TStringList.IndexOf: the list's comparison decides equality; a sorted list is searched by Find.

Examples

Searching, case-insensitively by default.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('Alpha');
        List.Add('Beta');
        Assert(List.IndexOf('Beta') = 1);
        Assert(List.IndexOf('gamma') = -1);
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.IndexOfItem, TSubstringList.Find