Пример #1
0
        static void Main(string[] args)
        {
            Drawing[] dobj = new Drawing[4];
            dobj[0] = new Line();
            dobj[1] = new Circle();
            dobj[2] = new Square();
            dobj[3] = new Drawing();

            foreach(Drawing draw in dobj){
                draw.Draw();
            }

            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Shape[] myShapes = new Shape[3];
            myShapes[0] = new Shape();
            myShapes[1] = new Circle() {Radius = 10};
            myShapes[2] = new Square();

            foreach (Shape shape in myShapes)
            {
                Console.WriteLine(shape.Draw());

                if (shape is Circle)
                {
                    Console.WriteLine("\t The radius is {0}", ((Circle)shape).Radius);
                }
            }

            Console.ReadLine();
        }