Exemple #1
0
        static void Polymorphism() // Олон хэлбэрт байдал
        {
            // virtual, override
            Animal myAnimal = new Animal(); // Create a Animal object
            Animal myPig    = new Pig();    // Create a Pig object
            Animal myDog    = new Dog();    // Create a Dog object

            myAnimal.AnimalSound();
            myPig.AnimalSound();
            myDog.AnimalSound();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Pig myPig = new Pig(); // Create a Pig object

            myPig.animalSound();
        }