uses System.Generics.Collections;
type
INamed = interface
function GetName: string;
end;
TFlower = class(TInterfacedObject, INamed)
function GetName: string;
end;
TCity = class(TInterfacedObject, INamed)
function GetName: string;
end;
TStar = class(TInterfacedObject, INamed)
function GetName: string;
end;
function TFlower.GetName: string;
begin
Result := 'Rose';
end;
function TCity.GetName: string;
begin
Result := 'Rome';
end;
function TStar.GetName: string;
begin
Result := 'Sirius';
end;
var
Rows: TList<INamed>;
Row: INamed;
List: string;
begin
Rows := TList<INamed>.Create;
Rows.Add(TFlower.Create);
Rows.Add(TCity.Create);
Rows.Add(TStar.Create);
List := '';
for Row in Rows do
begin
if List <> '' then
List := List + ', ';
List := List + Row.GetName;
end;
//list is 'Rose, Rome, Sirius'
WriteLn('list is ', List);
end.