c# 托管对象与InPtr互转

 

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

  GCHandle thisHandle = GCHandle.FromIntPtr(thisptr );
  MyClass thisObject = (MyClass)thisHandle.Target;

  

posted on 2014-11-27 20:29  柚子代码  阅读(971)  评论(0编辑  收藏  举报