I want to store some string data into a stack.
The Delphi Documentation for System.Generics.Collections.TStack is for Delphi XE4.
I read the answer of Mr. Heffernan in Missing units (IcePack, Generics.Collections)
What are some alternatives of stack aside from arrays?
Probably you are trying to use non-generic stack (that lives in System.Contnrs
).
Here is full working example for generic TStack<>
:
program ProjectC;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
System.Generics.Collections;
var
Stack: TStack<Integer>;
begin
Stack := TStack<Integer>.Create;
try
Stack.Push(1);
Stack.Push(2);
while Stack.Count > 0 do
Writeln(Stack.Pop);
finally
Stack.Free;
end;
Readln;
end.