delphi - How to store a set in a TStringList Object? -
I am trying to store a set within the object property (and read it) a TStringList (I use it I will also do it) to archive the text related to the set) but I get invalid typecast for the set
What is the best way to store a set inside a stringlist object? Also, do you need to free this object while destroying the stringlist?
Here are some example codes:
Type TDummy = (dOne, dTwo, dThree); TDummySet = Set of TDummy; Var Dummet: T-Dummy Set; SL: TStringList; Start SL: = TStringList.Create; Try DummySet: = [done, dThree]; SL.AddObject ('some string', toobject (dummet)); // does not work Invalid typed end SL.Free; End; End;
Read the other answers - you probably will get a low solution.
But FTR: You can write
SL.AddObject ('some string', tubact (byte (dummet));
and
Dummet: = Tidmisset (byte (SL Object [0]));
If you really want to.
Note: You must change the keyword byte
if you add enough element to the TDummySet type. For example, if you add six more elements (so in the total of nine) you need to insert the Word
.
Comments
Post a Comment