Пример #1
0
 static void ReferenceTypesAssignment()
 {
     Console.WriteLine("assigning value types \n");
     PointRef p1 = new PointRef(10, 10);
     PointRef p2 = p1;
     p1.Display();
     p2.Display();
     p1.X = 100;
     Console.WriteLine("\n change p1.X\n");
     p1.Display();
     p2.Display();
 }
Пример #2
0
        static void ReferenceTypeAssignment()
        {
            Console.WriteLine("=> ref type assignment");
            PointRef p1 = new PointRef(10, 10);
            PointRef p2 = p1;

            p1.Display();
            p2.Display();

            p1.X = 100;
            Console.WriteLine("=> changed p1.X");
            p1.Display();
            p2.Display();
            Console.WriteLine();
        }
Пример #3
0
        static void ReferenceTypeAssignment()
        {
            Console.WriteLine("Assigning reference type\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();
            p2.Display();
        }
Пример #4
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();
            p2.Display();
        }
Пример #5
0
        //Assigning to intrinsic value types results in
        //two independent variables on the stack.
        static void ValueTypeAssignment()
        {
            Console.WriteLine("Assinging value types\n");

            PointRef p1 = new PointRef(10, 10);
            PointRef p2 = p1;

            //Print both points.
            p1.Display();
            p2.Display();

            //Chage p1.X and print again. p2.X is changed to by reference
            p1.X = 100;
            Console.WriteLine("\n=> Changed p1.X\n");
            p1.Display();
            p2.Display();
        }
Пример #6
0
        static void ReferenceTypeAssignment()
        {
            // equals to method ValueTypeAssignment except the use of PointRef class
            Console.WriteLine("Assigning reference types: \n");
            PointRef p1 = new PointRef(10, 10);
            PointRef p2 = p1;

            p1.Display();
            p2.Display();

            //Изменить pl.X и снова вывести значения переменных.Значение р2.Х ИЗМЕНИЛОСЬ тк ссылочный тип.
            p1.X = 100;
            Console.WriteLine("\n=> Changed pl.X\n");
            p1.Display();
            p2.Display();
            Console.WriteLine();
        }
Пример #7
0
        static void ReferenceTypeAssignment()
        {
            Console.WriteLine("Assigning reference types\n");
            PointRef p1 = new PointRef(10, 10);
            PointRef p2 = p1; // p2 now POINTS to the location in memory of p1

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

            // Change p1.y and print again
            p1.y = 99;
            Console.WriteLine("\n=> p1.y changed\n");
            p1.Display();
            p2.Display();

            // In this case there are two references pointing to the same
            // object on the managed heap.
        }
Пример #8
0
        static void ReferenceTypeAssignment()
        {
            Console.WriteLine("Assigning reference types\n");
            PointRef p1 = new PointRef(10, 10);
            PointRef p2 = p1;

            p1.Display();
            p2.Display();

            p1.X = 100;
            Console.WriteLine("\n=> Changed p1.X\n");
            p1.Display();
            p2.Display();
        }