小编V.K*_*pov的帖子

Delphi XE中的类型转换问题

我尝试用这种方式列出程序:

type

TProc = procedure of object;

TMyClass=class
private
fList:Tlist;
function getItem(index:integer):TProc;
{....}
public
{....}
end;
implementation
{....}
function TMyClass.getItem(index: Integer): TProc;
begin
 Result:= TProc(flist[index]);// <--- error is here!
end;
{....}
end.
Run Code Online (Sandbox Code Playgroud)

并得到错误:

E2089无效的类型转换

我该如何解决?正如我所看到的,我可以制作一个只有一个属性的假类Proc:TProc;并列出它.但我觉得这是一个糟糕的方式,不是吗?

PS:项目必须与delphi-7兼容.

delphi delphi-7 delphi-xe

2
推荐指数
1
解决办法
1128
查看次数

标签 统计

delphi ×1

delphi-7 ×1

delphi-xe ×1