c# 托管对象与InPtr互转

 

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

  GCHandle thisHandle = GCHandle.FromIntPtr(thisptr );
  MyClass thisObject = (MyClass)thisHandle.Target;
相关文章
相关标签/搜索