I am trying to save a set inside an object property (and read it) in a TStringList (I will also use it to store the text associated with the set), but I get an invalid type for the set.
What is the best way to save a set inside a StringList? Also, should this object be freed when the StringList is destroyed?
Here is a sample code:
type
TDummy = (dOne, dTwo, dThree);
TDummySet = set of TDummy;
var
DummySet: TDummySet;
SL: TStringList;
begin
SL := TStringList.Create;
Try
DummySet := [dOne, dThree];
SL.AddObject('some string', TObject(DummySet)); // Doesn't work. Invalid typecast
Finally
SL.Free;
End;
end;
source
share