Delphi erlaubt hier aber nur Listen von variabler Länge, nicht "Array [0..1] of string".
Delphi-Quellcode:
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
TAbcPair =
Array [0..1]
of string;
TSomeList =
Array of TAbcPair;
procedure Test(
const A2DStringArray: TSomeList);
begin
for var SingleStringArray
in A2DStringArray
do
begin
for var SingleString
in SingleStringArray
do
begin
Writeln(SingleString);
end;
end;
end;
procedure Test2(
const A2DStringArray: TAbcPair);
begin
for var SingleStringArray
in A2DStringArray
do
begin
Writeln(SingleStringArray);
end;
end;
begin
try
Test([['
1', '
2'], ['
3', '
4']]);
// <- Inkompatible Typen: 'TAbcPair' und 'Set'
Test2(['
1', '
2']);
// <- Inkompatible Typen: 'TAbcPair' und 'Set'
var liste : TAbcPair;
liste[0] := '
5';
liste[1] := '
6';
Test([liste]);
// <- Alles cool
Test2(liste);
// <- Alles cool
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
end.