Strings
property Strings[Index: Integer]: string read write; default;
Example
procedure NormaliseFirst(const Items: TStringList);
begin
if Items.Count > 0 then
Items.Strings[0] := 'Normalised';
end;
Usage
Strings gets or replaces the string at a zero-based index through the string list's default indexed property.
- Check bounds against
Count. - Do not write an entry in a sorted
TStringList; remove/re-add through its sorting policy instead. - Saved indexes can become stale after any insertion, deletion, move or sort.
Additional Technical Info
Strings is declared by hidden ancestor TStrings and is normally used through a concrete visible descendant such as TStringList. Because it is the default property, Items[0] and Items.Strings[0] are equivalent in script.
Source-backed behaviour
The read accessor is abstract in TStrings. The base write accessor preserves the current object reference, deletes the entry and reinserts the new text at the same index; that multi-step path can be partially destructive. TStringList overrides the setter with an in-place text assignment, bounds checks and notifications, but rejects all string replacement when Sorted=True to protect ordering.
Valid indexes are 0..Count-1. Assigning text containing NameValueSeparator makes it visible through the name/value properties but does not create separate storage.
Related members
Objects is the paired association. Add, Insert and Delete change the indexed set.