开发者

Using Angle Brackets (I have seen people using TList<PSomething>)

I see people declaring their TLists l开发者_开发技巧ike

MyList : TList<PSomeType>;

Whereafter when they create it, they do

MyList := TList<PSomeType>.Create;

So I asume that by doing that, they won't have to typecast the MyList.Items[I] whenever they are using it, like:

ShowMessage( PSomeType(MyList.Items[I]).SomeTextProperty );

So instead they would just do

ShowMessage( MyList.Items[I].SomeTextProperty );

Is that correct?

If so, then why can't I get it to work in Delphi 2010? I am trying exactly that - Declaring my list as

MyList : TList<PSomeType>;

But the compiler says:

Undeclared Identifier: TList<>

What am I doing wrong there?


These people are using a generic list. TList<T> is a generic version of TList, and it's declared in the unit Generics.Collections, not in Classes, where TList is. Add Generics.Collections to your uses list and you should be fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜