int a = 3;
GCHandle handle = GCHandle.Alloc(a);
var pin = GCHandle.ToIntPtr(handle);
Console.WriteLine(pin);