Delphi自定义函数返回数组解决方法

一月 27, 2010 at 7:50 下午Easton
type   
        TArr   =   array   of   integer;   
    
  function   abc(a:integer):Tarr;   
  var   
          tempArr:TArr;   
  begin   
          setlength(tempArr,2);   
          tempArr[0]   :=   a;   
          tempArr[1]   :=   a   +   10;   
          result:=tempArr;   
  end;   
    
  procedure   TForm1.Button1Click(Sender:   TObject);   
  var   
          a   :   integer;   
  begin   
          a   :=   5;   
          showmessage(inttostr(       abc(a)[0]       ));     //5   
          showmessage(inttostr(       abc(a)[1]       ));     //15   
  end;

Posted in: 技术文章

Tags: , , ,

添加评论

  Country flag

biuquote
  • 评论
  • 在线预览
Loading