Ejemplo n.º 1
0
        public static void Polymorphism()
        {
            Animal animal = new Animal();
            Bird   bird   = new Bird();

            Dog spot   = new Dog();
            Cat fluffy = new Cat();

            animal = spot;

            animal.Speak();          //Woof!

            (animal as Dog).Speak(); //Woof!


            /*
             *          dog = animal;
             *
             *          dog = animal as Dog;
             */


            Vet v = new Vet();

            v.Heal(spot);
            v.Heal(bird);
            v.Heal(animal);
        }