使用角括号(我看到人们使用TList< PSomething>) [英] Using Angle Brackets (I have seen people using TList<PSomething>)

查看:191
本文介绍了使用角括号(我看到人们使用TList< PSomething>)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到有人声明他们的TList如

I see people declaring their TLists like

MyList : TList<PSomeType>;

之后,当他们创建它

MyList := TList<PSomeType>.Create;

所以我假设通过这样做,他们不会类型转换MyList.Items [I]每当他们使用它,如:

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 );

因此,他们只是做

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

是否正确?

,那为什么我不能让它在德尔福2010年工作?我正在尝试 - 声明我的列表为

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> ;;

但是编译器说:


未声明的标识符:TList<>

Undeclared Identifier: TList<>

我在这里做错了什么?

推荐答案

正在使用通用列表。 TList< T> 是TList的通用版本,它在单元 Generics.Collections code> Classes ,其中 TList 是。在使用列表中添加 Generics.Collections 即可。

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.

这篇关于使用角括号(我看到人们使用TList&lt; PSomething&gt;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆