I want to convert an string to an enum type using TValue, I googled but I didn't find how to do that.
type
TEnumTest = (etFirst, etSecond);
var
D: TEnumTest;
begin
D := StrToENumTest('etFirst');
end;
function StrToEnumTest(pStr:String):TEnumTest;
var
V: TValue;
begin
V := TValue.From<String>(pstr);
Result := V.AsType<TEnumTest>;
end;
It doesn't work. That's must be something stupid I'm not seeing - but I didn't found it. What I made wrong?
I know how to use GetEnumValue.