I want to store a pointer to a native class in System::Object^
and retrieve it back.
class ABC;
ABC * d = new ABC();
System::Object^ Tag;
Tag = d; //This throws an error
//in a different function
ABC * c = safe_cast<ABC*>Tag; // this throws an error.
Wh开发者_如何学JAVAich is the proper way to achieve the above behavior?
Use IntPtr structure instead of Object.
IntPtr Tag(d); ABC * c = (ABC*)Tag.ToPointer();
精彩评论