返加variant類型就可以了。
給你一個例子(返回len1個大于等于min1,小于等于max1的隨機數組):
function result1(len1,min1,max1:integer):variant;
var i,j:integer;
list1:tstringlist;
str1:string;
begin
list1:=tstringlist.Create;
result:=VarArrayCreate([0,len1-1],varvariant);
randomize;
for i:=0 to len1-1 do
begin
j:=random(max1-min1)+min1;
while list1.IndexOf(inttostr(j))<>-1 do
j:=random(max1-min1)+min1;
list1.Add(inttostr(j))
end;
for i:=0 to list1.Count-2 do
for j:=i+1 to list1.Count-1 do
begin
if strtoint(list1)>strtoint(list1[j]) then
begin
str1:=list1;
list1:=list1[j];
list1[j]:=str1;
end;
end;
for i:=0 to list1.Count-1 do
result:=list1;
list1.Free;
end;