Пример #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();
 }
Пример #2
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();
        }
Пример #3
0
        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();
        }
Пример #4
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();
        }