TStringList vs. TList

前端 未结 8 2008
野性不改
野性不改 2021-02-05 02:31

what is the difference in using a standard

type 
  sl: TStringList 

compared to using a generic TList

type 
  sl: TList

        
8条回答
  •  感动是毒
    2021-02-05 03:07

    TStringList has been used for far too long and has many advantages, all mentioned by Rob Kennedy.

    The only real disadvantage of using it as a pair of a string and an object is the necessity of casting object to the actual type expected and stored in this list (when reading) and as far as I know Embarcadero did not provide Delphi 2009 and up VCL libraries with generic version of TStringList.

    To overcome this limitation I implemented such list for internal use and for almost 3 years it serves it's purpose so I decided to share it today: https://github.com/t00/deltoo#tgenericstringlist

    One important note - it changes the default property from Strings to Objects as in most cases when object is stored in a list it is also the mostly accessed property of it.

提交回复
热议问题