首页 > 代码库 > c# 托管对象与InPtr互转

c# 托管对象与InPtr互转

 

  GCHandle thisHandle = GCHandle.Alloc(this);//this 是  MyClass类型  IntPtr thisptr = GCHandle.ToIntPtr(thisHandle);  GCHandle thisHandle = GCHandle.FromIntPtr(thisptr );  MyClass thisObject = (MyClass)thisHandle.Target;

  

c# 托管对象与InPtr互转