Generic List in XE4

119 views Asked by At

I get a compiler error message

[dcc32 Error] Unit1.pas(18): E2003 Undeclared identifier: 'TList<IInterface>'

in Delphi XE4 when I do this:

uses
  Classes;

TMyClass = class
  private
    fIList : TList<IInterface>;
end;

Should I enable generics by a compiler option? Because when I remove the generic definition, it compiles. Other case it underline TList and IInterface as well.

1

There are 1 answers

0
Dalija Prasnikar On BEST ANSWER

You need to add the System.Generics.Collections unit to your uses clause.

This is where the TList<T> class is implemented, and the compiler will not find it unless you tell it where to look.