Q
qi_jianzhou
Unregistered / Unconfirmed
GUEST, unregistred user!
在看 .net 的委托时想到了欢迎大家讨论ps:不要看我的变量命名,我是随意命名的--------------unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TTestProd = procedure (aName:string); TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure showName(aaa:TTestProd;aName:string); //procedure show1(aName:string); //procedure show2(aName:string); public { Public declarations } end;procedure show1(aName:string);procedure show2(aName:string);var Form1: TForm1;implementation{$R *.dfm}{ TForm1 }{ TForm1 }procedure show1(aName: string);begin ShowMessage('中车'+aName);end;procedure show2(aName: string);begin ShowMessage('中车222'+aName);end;procedure TForm1.showName(aaa: TTestProd; aName: string);begin aaa(aName);end;procedure TForm1.Button1Click(Sender: TObject);var at:TTestProd; f:TForm1;begin f := TForm1.Create(Application); at := show1; self.showName(at,'aaa'); at := show2; self.showName(at,'aaabbbb');end;end.