Esempio n. 1
0
        public static void DrawDemo()
        {
            DrawingObject[] dObj = new DrawingObject[5];

            dObj[0] = new Line1();
            dObj[1] = new Line2();
            dObj[2] = new Circle();
            dObj[3] = new Square();
            dObj[4] = new DrawingObject();

            foreach (DrawingObject drawObj in dObj)
            {
                drawObj.Draw();
            }

            var line1 = new Line1(); // if modifier isn`t be like in base e.g. class method as "protected void Draw()"  CLR calling base class method Draw

            line1.Draw();
            var line2 = new Line2(); // but if modifier declared as protected internal CLR calling derived class method Draw

            line2.Draw();
            var circle = new Circle();

            circle.Draw();
        }