小编Mar*_*ima的帖子

如何在Delphi中扩展Generic Collection?

我有一个像这样的Generic集合:

TFoo = class;

TFooCollection<T: TFoo> = class(TObjectDictionary<string, T>)
   procedure DoSomething;
end;
Run Code Online (Sandbox Code Playgroud)

它工作正常.

现在我需要像这样扩展TFooCollection:

TBar = class( TFoo );   

TBarCollection<T: TBar> = class(TFooCollection)
   procedure DoSomethingElse;
end;
Run Code Online (Sandbox Code Playgroud)

并且编译器抱怨没有定义TFooCollection.由于TBar继承自TFoo,我想利用TFooCollection方法(可以使用TFoo和TBar项目)并使用TBar Collections做其他事情.

德尔福有可能吗?

delphi generics collections

4
推荐指数
1
解决办法
306
查看次数

标签 统计

collections ×1

delphi ×1

generics ×1