How to create an empty list of strings in Pascal

1 Answer

0 votes
program EmptyStringListExample;

uses
  Classes; // TStringList

var
  StringList: TStringList;
  ListSize: Integer;
begin
  // Create an empty TStringList
  StringList := TStringList.Create;

  // Get the size of the list (number of strings in it)
  ListSize := StringList.Count;

  // Output the size of the list
  WriteLn('The size of the list is: ', ListSize);

  // Free the TStringList to avoid memory leaks
  StringList.Free;
end.




(*
run:
  
The size of the list is: 0
  
*)

 



answered Jul 22, 2025 by avibootz
...