How to set NULL to Variant field using rtti

delphi, null, rtti

Solution

This works:

Field.SetValue(Self, TValue.From<Variant>(Null) );

Problem

I have a problem setting null to a variant field using rtti. Suppose I have class like this: ``` TClass1 = class Field1:Integer; Field2:Variant; end; ``` when I get access to a Field1 I can do: ``` Field.SetValue(TObject(ValueObject.AsObject), 1); ``` but it seems I can not do this with Field2: ``` Field.SetValue(TObject(ValueObject.AsObject), null); ``` or ``` Field.SetValue(ValueObject.AsObject, TValue.FromVariant(NULL)); ``` So, what I want is to be able to set null value to a Field2 of class above. Is it possible? Any ideas would be appreciated. Goran

Original source