// Unsafe method: takes a pointer to an int.
unsafe static void SquarePtrParam(int* p)
{
*p *= *p;
}
unsafe static void SquarePointValue()
{
Point pt = new Point
{
x = 5,
y = 6
};
// Pin pt in place:
fixed (int* p = &pt.x)
{
SquarePtrParam(p);
}
// pt now unpinned.
Console.WriteLine("{0} {1}", pt.x, pt.y);
/*
Output:
25 6
*/
}