コード例 #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());
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: lyapinasvetlana/Work
        static void Interface()
        {
            //часто сравнивают с  контрактами
            //унифицированная работа
            ICollection collection = new BaseList(4);

            collection.Add(1);
        }
コード例 #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);
        }
コード例 #4
0
        static void InterfaceExtensionCall()
        {
            //чтобы убедиться что интерфейс расширился
            //и проверить работу кода, воспользуйся дебагом
            List <object> list = new List <object>()
            {
                1, 2, 3
            };
            IBaseCollection collection = new BaseList(4);

            collection.AddRange(list);
        }