TSubstringList.AddObject Method

function AddObject(const S: string; const AObject: TObject): Integer; overload;

Adds S with the object AObject, as Add.

#NameDescription
1S

The text, every text kind; it may be an item of this list.

2AObject

The item's object; with OwnsObjects the list frees it.

Returns: Integer - The new item's index.

Examples

An item with its object.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.AddObject('self', List);
        Assert(List.Objects[0] = List);
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.Objects, TSubstringList.InsertObject, TSubstringList.IndexOfObject