views:

328

answers:

1

Hello, 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.

+6  A: 

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.

Michael Madsen
Thanks Very much
Salvador