我在Delphi XE2中过去几天一直在使用第三方服务,而且几乎已经完成了。我遇到了一个绝对难以理解的问题,我认为应该有非常明显的答案。我希望另一双眼睛可以告诉我我的问题是什么。
我有这个界面:
IWorshipTeamEvent = Interface(IInterface)
function GetId : integer;
function GetName : string;
function GetTeamId : integer;
function GetStartDate : TDate;
function GetEndDate : TDate;
function GetStartTime : TTime;
function GetEndTime : TTime;
function GetSets : IWorshipTeamSetList;
property Id : integer read GetId;
property Name : string read GetName;
property TeamId : integer read GetTeamId;
property StartDate : TDate read GetStartDate;
property EndDate : TDate read GetEndDate;
property StartTime : TTime read GetStartTime;
property EndTime : TTime read GetEndTime;
property Sets : IWorshipTeamSetList read GetSets;
end;
然后在同一单元的另一个类中,我试图在此函数中返回IWorshipTeamEvent
:
function TWorshipTeamEventList.GetEvent(index: Integer) : IWorshipTeamEvent;
begin
//fEvents is a TInterfaceList that contains only IWorshipTeamEvents
Result := fEvents[index] as IWorshipTeamEvent;
end;
此时,我收到编译器错误Operator not applicable to this operand type
。我尝试了一些方法,比如创建一个temp
变量,其类型为IXmlResponseType
并且正在进行
temp := fEvents[index] as IXmlResponseType;
Result := nil;
汇编了,所以我尝试创建temp
类型为IWorshipTeamEvent
并且
temp := fEvents[index] as IWorshipTeamEvent;
Result := nil;
没有编译。
非常感谢任何建议