示例#1
0
        static void ReferenceTypeAssignment()
        {
            Console.WriteLine("Assigning reference types\n");
            PointRef p1 = new PointRef(10, 10);
            PointRef p2 = p1;

            // Print both point refs
            p1.Display();
            p2.Display();

            // Change p1.X and print again
            p1.X = 100;
            Console.WriteLine("\n=> Changed p1.X\n");
            p1.Display();
            // Since p2 tracks the same reference, it's X value also changes
            p2.Display();
        }