代码:
using System.Runtime.InteropServices;
using System;
namespace ConsolePrototype
{
public class A
{
}
class Program
{
static void Main(string[] args)
{
A a = new A();
GCHandle hander = GCHandle.Alloc(a);
var pin = GCHandle.ToIntPtr(hander);
Console.WriteLine(pin);
}
}
}