TSubstringList.DeleteRange Method

procedure DeleteRange(const Index, ACount: Integer);

Deletes ACount items from Index, as TList<T>.DeleteRange.

#NameDescription
1Index

The first item's index.

2ACount

The number of items.

Result: stored in self (calling object)

Remarks:

The range must lie inside the list, else EArgumentOutOfRangeException is raised. With OwnsObjects the objects are freed.

Examples

Deleting a run of items.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('a');
        List.Add('b');
        List.Add('c');
        List.DeleteRange(0, 2);
        Assert(List.Count = 1);
        Assert(List[0] = 'c');
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.Delete, TSubstringList.Clear