Delete
procedure Delete(Index: Integer);
Example
procedure RemoveFirst(const Items: TStringList);
begin
if Items.Count > 0 then
Items.Delete(0);
end;
Usage
Delete invokes the string list's abstract operation to remove the entry at a zero-based index.
- Validate indexes against the live
Count; deletion shifts every later index down by one. - Any saved reference to the deleted string entry becomes stale. An associated borrowed object remains independently owned elsewhere.
- In an owning string list, object destruction can raise after the entry was removed.
Additional Technical Info
Delete is declared by hidden ancestor TStrings and is normally used through a concrete visible descendant such as TStringList. Index validation, object lifetime and notification behaviour come from the concrete list.
Source-backed behaviour
TStrings.Delete is abstract. TStringList.Delete requires 0 <= Index < Count, emits a changing notification, removes the managed string/object pair, compacts later entries, optionally frees the associated object when the native list owns objects, then emits changed.
The parameterless script-created TStringList is non-owning, so its associated object is merely detached. Other descendants can implement different storage or ownership rules.
Related members
Clear removes all entries. Move internally detaches an object before deleting its old entry. Objects exposes associations.