Example #1
0
 static void ValueTypeContainingRefType()
 {
     Console.WriteLine("creating r1");
     Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);
     Console.WriteLine("assigning r2 to r1");
     Rectangle r2 = r1;
     Console.WriteLine("changing r2");
     r2.rectInfo.infoString = "this is new string";
     r2.rectBottom = 4444;
     r1.Display();
     r2.Display();
 }
Example #2
0
        private static void ValueTypeContainingsRefType()
        {
            Console.WriteLine("-> Creating r1");
            Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);

            Console.WriteLine("-> Assigning r2 to r1");
            Rectangle r2 = r1;

            Console.WriteLine("-> Changing values of r2");
            r2.rectInfo.infoString = "This is new info!";
            r2.rectBottom          = 444;
            r1.Display();
            r2.Display();
        }
Example #3
0
        private static void ValueTypeConteiningRefType()
        {
            Console.WriteLine("=> Creating first rectangle");
            Rectangle rect1 = new Rectangle("Firt rect", 10, 12, 34, 55);

            Console.WriteLine("=> Assigning to second rectangle");
            Rectangle rect2 = rect1;

            Console.WriteLine("=> Changing info in rect2");
            rect2.rectInfo.infoString = "New rect info";
            rect2.rectBottom          = 777;
            rect1.Display();
            rect2.Display();
        }
Example #4
0
        static void ValueTypeContainingRefType()
        {
            Console.WriteLine("=>Creating r1");

            Rectangle r1 = new Rectangle("First rect", 10, 10, 50, 50);

            Console.WriteLine("Assinning r2 to r1");
            Rectangle r2 = r1;

            Console.WriteLine("Changing r2");
            r2.rectInfo.infoString = "Second rect";
            r2.rectTop             = 12;

            r1.Display();
            r2.Display();
        }
Example #5
0
        private static void ValueTypeContainingRefType()
        {
            // Create the first Rectangle.
            Console.WriteLine("-> Creating r1");
            Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);
            // Now assign a new Rectangle to r1.
            Rectangle r2 = r1;

            // Change some values of r2.
            Console.WriteLine("-> Changing some values of r2");
            r2.rectInfo.infoString = "This is new info!";
            r2.rectBottom          = 4444;
            // print values of both rectangles.
            r1.Display();
            r2.Display();
            Console.WriteLine();
        }
Example #6
0
        static void ValueTypeContainingRefType()
        {
            Console.WriteLine("=> value type containing ref type");
            Console.WriteLine("Creating r1");
            Rectangle r1 = new Rectangle("Firct Rect", 10, 10, 50, 50);

            Console.WriteLine("Assingning r1 to r2");
            Rectangle r2 = r1;
            Console.WriteLine("Change r2");
            r2.rectInfo.infoString = "New Info";
            r2.Bottom = 4444;

            r1.Display();
            r2.Display();


            Console.WriteLine();
        }
Example #7
0
        static void ValueTypeContainingRefType()
        {
            // Создать первую переменную Rectangle.
            Console.WriteLine("-> Creating r1");
            Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);

            // Присвоить новой переменной Rectangle переменную rl.
            Console.WriteLine("-> Assigning r2 to r1");
            Rectangle r2 = r1;

            // Изменить некоторые значения в r2.
            Console.WriteLine("-> Changing values of r2");
            r2.RectInfo.InfoString = "This is new info!";
            r2.RectBottom          = 4444;
            // Вывести значения из обеих переменных Rectangle,
            r1.Display();
            r2.Display();
        }
        static void ValueTypeContainingRefType()
        {
            //  Create the first Rectangle.
            Console.WriteLine("-> Creating r1");
            Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);

            //  Now assign a new Rectangel to r1.
            Console.WriteLine("-> Assigning r2 to r1");
            Rectangle r2 = r1;

            //  Change some values of r2.
            Console.WriteLine("-> Changing values of r2");
            r2.rectInfo.infoString = "This is new info!";
            r2.rectBottom = 4444;

            //  Print values of both rectangles.
            r1.Display();
            r2.Display();
        }
Example #9
0
        static void Main(string[] args)
        {
            ValueTypeAssignment();
            ReferenceTypeAssignment();

            // Create the first rectangle
            Console.WriteLine("-> Creating r1");
            Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);

            // Now assign a new Rectangle to r1
            Console.WriteLine("-> Assigning r2 to r1");
            Rectangle r2 = r1;

            // Change some values of r2.
            Console.WriteLine("-> Changing values of r2");
            r2.rectInfo.infoString = "This is some new info!";
            r2.rectBottom          = 1245;

            // Print both of the rectangles.
            r1.Display();
            r2.Display();

            Console.ReadLine();
        }
Example #10
0
        static void ValueTypeContainingRefType()
        {
            Console.WriteLine("-> Creating r1");
            Rectangle r1 = new Rectangle("First Rect", 10, 10, 50, 50);

            Console.WriteLine("-> Assigning r2 to r1");
            Rectangle r2 = r1;

            Console.WriteLine("-> Change values of r2");
            r2.rectInfo.infoString = "This is new info!";
            r2.rectBottom = 4444;

            r1.Display();
            r2.Display();
        }