c# 託管對象與InPtr互轉

 

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

  GCHandle thisHandle = GCHandle.FromIntPtr(thisptr );
  MyClass thisObject = (MyClass)thisHandle.Target;
相關文章
相關標籤/搜索