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(); }
static void Main(string[] args) { Pig myPig = new Pig(); // Create a Pig object myPig.animalSound(); }