开发数组的参数赋值和传参如下:
代码如下:
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure ShowMsg (FormatStr: string; Params: array of const); begin Form1.Memo1.Lines.Add(‘输出: ‘ + Format (FormatStr, Params)); end; procedure TForm1.Button2Click(Sender: TObject); begin ShowMsg(‘参数一为:%d,参数二为:%d,参数三为:%d‘, [33,44,520]); end; end.
时间: 2024-11-04 18:23:11