Can I create a general list of a specific interface in Delphi?

In C #, I can create a generic list containing a specific interface, for example:

myList = List<IMyInterface>; 

Can I do the same in Delphi XE3, and if so, how?

I know that I can create a TInterfaceList to store a list of interfaces, but it is not very typed, so I still need to use it when using objects in the list.

Is there a strictly typed way to do this?

+4
source share
1 answer

Delphi supports the generic List TList<T> , which can be used with a specific interface, for example:

 var List: TList<IMyInterface>; begin List := TList<IMyInterface>.Create; {..Do something with list..} List.Free; end; 
+14
source

Source: https://habr.com/ru/post/1437024/


All Articles