简体   繁体   中英

Replacement for TList in Delphi Prism.

I am migrating an application written in Delphi 2007 to Delphi Prism, which is the best option to replace the TList class?

Thanks in advance.

Bye.

You don't specify if you mean the plain TList or the generic TList introduced with generics in D2009, although I have a feeling it's the plain TList.

Use List<T> if you want to use generics. That means you don't have to do manual typecasting every time you take something out of your list. In general, you would probably want to use this one unless you have a specific reason not to. You should also use this if you are already using TList in your Delphi application - if memory serves, CodeGear deliberately adapted the interface from the .NET List when adding generics in D2009.

If you want a non-generic version, which just stores Objects (much like TList), look at ArrayList . This maps more closely to your current implementation (assuming plain TList), but you lose the compile-time type safety you can get from using generics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM