Exemplo n.º 1
0
        static void CallThroughInterface()
        {
            // IBaseCollection collection = new IBaseCollection();

            List <object> list = new List <object>()
            {
                1, 2, 3
            };

            IBaseCollection collection = new BaseList(4);

            collection.Add(1);
            collection.AddRange(list);

            Console.WriteLine(collection);

            // Shape shape = new Shape();

            Shape[] shapes = new Shape[2];

            shapes[0] = new Triangle(10, 20, 30);
            shapes[1] = new Rectangle(10, 20);

            foreach (var shape in shapes)
            {
                shape.Draw();
                Console.WriteLine(shape.Perimeter());
            }
        }
Exemplo n.º 2
0
        static void Interface()
        {
            //часто сравнивают с  контрактами
            //унифицированная работа
            ICollection collection = new BaseList(4);

            collection.Add(1);
        }
Exemplo n.º 3
0
        static void CollingInterface()
        {
            List <object> list = new List <object>()
            {
                1, 2, 3
            };
            IBaseCollection collection = new BaseList(4);

            collection.AddRange(list);
            collection.Add(1);
        }