问题
I am migrating an application written in Delphi 2007 .Net to Delphi Prism, which is the best option to replace the TStringList and TStrings class?
Thanks in advance.
Bye.
回答1:
Just use the built in List types in the .NET framework, or the StringCollection.
The easiest are the generic lists:
List<String>
But StringCollection has a few bits that the List does not have; you can read a bit about that in this thread.
The advantage of using built-in .NET Framework classes, is that there is plenty documentation at MSDN, have loads of examples (for instance atCodeProject), and usually support more features (like implementing required interfaces to do data binding and such: the TStringList in ShineOn does not do that).
The advantage of using VCL like things is that you are more familiar with the VCL so it gets you started quicker. But there is a reason why VCL.NET has not been developed further...
Janka Janos has a great comparison chart of features in C# and Delphi Prism. That will help you translate C# examples into Delphi Prism code.
--jeroen
回答2:
Have you looked at ShineOn? It has a Classes.pas with TStringList in it.
回答3:
I have used Collections.Specialized.HybridDictionary (and similar) classes in the little bit of C# I have done. As it is a standard .net object it should be available in Prism.
I don't know if it has a LoadFrom/Save to file though
来源:https://stackoverflow.com/questions/1382395/replacement-for-tstringlist-in-delphi-prism