动态数组传递数据示例 - 回复 YinGaGa 的问题

动态数组传递数据示例 - 回复 YinGaGa 的问题


问题来源: http://www.cnblogs.com/del/archive/2008/10/14/1310583.html#1673278

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

Type
  TMyByteArr = array of Byte;

procedure Proc(inArr: TMyByteArr; var OutArr: TMyByteArr);
begin
  SetLength(OutArr, Length(inArr));
  Move(inArr, outArr, Length(inArr));
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  arr1,arr2: TMyByteArr;
  i: Integer;
  str: string;
begin
  SetLength(arr1, 3);
  arr1[0] := 11;
  arr1[1] := 22;
  arr1[2] := 33;

  Proc(arr1, arr2);
  for i := 0 to Length(arr2) - 1 do str := Format('%s %d', [str, arr2[i]]);
  ShowMessage(TrimLeft(str)); {11 22 33}
end;

end.
posted on 2009-10-16 14:03  万一  阅读(4742)  评论(22)  编辑  收藏
上一篇:...扩展运算符和rest运算符


下一篇:学习c语言的21天