Count
property Count: Integer read;
Example
procedure ReadLast(const Items: TStringList; var LastValue: string);
begin
if Items.Count = 0 then
LastValue := ''
else
LastValue := Items[Items.Count - 1];
end;
Usage
Count returns the list's current number of valid zero-based string entries.
- Re-read Count when other code can mutate the list.
- Guard empty lists before calculating
Count - 1. - Do not iterate concurrently with mutation unless the workflow supplies external synchronisation.
Additional Technical Info
Count is declared by hidden ancestor TStrings and is normally used through a concrete visible descendant such as TStringList. The base accessor is abstract and every storage-bearing descendant must implement it.
Source-backed behaviour
Valid indexed positions are 0 through Count - 1; a zero count means no valid index. The property is live and can change after add, insert, delete, clear, text/delimited assignment, load or event-driven mutation.
Count is not Capacity, a byte size or a character count. Reading it does not snapshot the collection or lock it.
Related members
Strings and Objects use this index range. Capacity is allocation headroom.