c# 对象,IntPtr互转
2021-01-07 09:28
标签:int ring handle str rom from free class string c# 对象,IntPtr互转 标签:int ring handle str rom from free class string 原文地址:https://www.cnblogs.com/Angel-szl/p/13152629.html struct aa
{
public string a;
public string b;
}
aa p = new aa();
p.a = "1";
p.b = "1";
//对象转IntPtr
var handle = GCHandle.Alloc(p);
var ptr = GCHandle.ToIntPtr(handle);
//IntPtr转对象
var a = GCHandle.FromIntPtr(ptr)
.Target;
handle.Free();
上一篇:C#中的委托