来自降序类的不兼容类型TObjectList <t>

时间:2017-03-24 13:00:42

标签: delphi generics

我有一个基类

  TPart = class
  private   
    FPartId: Integer;
  public
    property PartId: Integer read FPartId write FPartId;
  end;

一个继承的类

TPartTwo = class(TPart)
  private   
    FDesc: String;
  public
    property Desc: String read FDesc write FDesc;
  end;

我有一个将对象加载到Tlistobject

的函数
function LoadItems<T: class, constructor>(aID: Integer; aInstanceOwner: Boolean = True): TObjectList<T>;

我想将一些TListObect<TPartTwo>传递给TListObject<TPart>。这可能吗?有人可以帮我指出正确的方向吗?

function TPartAgent.GetBackOrderByPart(aPartID: Integer): TObjectList<TPart>;
begin
  ...
  Result:= self.LoadItems<TPartTwo>(aPartID) ; //loaditems give a TObjectList of TPartTwo
  ...
end;

0 个答案:

没有答案
相关问题