program Test_Method;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
TExec = procedure of object;
var
_func: TMethod;
Exec: TExec;
procedure Test1;
begin
Writeln('Hell, word! This is a procedure.');
end;
function Test2: Boolean;
begin
Writeln('Hell, word! This is a function.');
Result := True;
end;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
_func.Code := @Test1;
_func.Data := nil;
Exec := TExec(_func) ;
Exec;
_func.Code := @Test2;
_func.Data := nil;
Exec := TExec(_func) ;
Exec;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)