Пример #1
0
        private void AbstractFactoryDesignPattern()
        {
            // create objects using Abstract Factory Design Pattern
            var createTiger = new AnimalMaker();

            createTiger.CreateAnimal();
        }
        static void ReturnTypeCovariance()
        {
            Giraffe giraffe = new Giraffe();

            // This is an example of method group being covariant in their
            // return types. The delegate definition very clearly wants an
            // Animal from the method group but the definition of MakeGiraffe
            // returns a giraffe.
            // From the article at Eric Lippert's blog: http://goo.gl/bpDPPX
            // "The caller of func is never going to get anything that they’re
            // not capable of dealing with."
            AnimalMaker animalMaker = new AnimalMaker(giraffe.MakeGiraffe);
        }