C# unsafe code fixed pointer passed as parameter
问题 I came across the following code on msdn: unsafe static void SquarePtrParam (int* p) { *p *= *p; } unsafe static void Main() { Point pt = new Point(); pt.x = 5; pt.y = 6; // Pin pt in place: fixed (int* p = &pt.x) { SquarePtrParam (p); } // pt now unpinned. Console.WriteLine ("{0} {1}", pt.x, pt.y); } I am just wondering, we are directly accessing pointer in SquarePtrParam function, does it inherit information that array is fixed from calling method? Why don't we need to explicitly set it to