TSubstringList.IndexOfObject Method

function IndexOfObject(const AObject: TObject): Integer;

The index of the first item whose object is AObject, or -1.

#NameDescription
1AObject

The object searched for; nil finds the first item without one.

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

Examples

Finding an item by its object.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(2);
    try
        List.AddObject('a', nil);
        List.AddObject('b', List);
        Assert(List.IndexOfObject(List) = 1);
        Assert(List.IndexOfObject(nil) = 0);
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.Objects, TSubstringList.AddObject