Why can't Delphi variants hold objects?

前端 未结 3 2225
时光说笑
时光说笑 2021-02-13 09:14

Why can\'t Delphi variants hold objects? More importantly, what\'s the reason behind this limitation?

3条回答
  •  误落风尘
    2021-02-13 09:30

    You can definitely store an object inside a Variant variable - just cast it into a NativeUInt. An object is just a pointer, anyway.

    obj := TObject.Create;
    v := NativeUInt(obj);
    obj := TSomeObject(NativeUInt(v));
    

提交回复
热议问题