Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- Dog dog = new Dog();
- dog.MakeSound(); // Bark!
- Cat cat = new Cat();
- cat.MakeSound(); // Meow!
- }
- }
- interface Animal
- {
- void MakeSound();
- }
- class Dog : Animal // Класът Куче имплементира Животно
- {
- public void MakeSound()
- {
- Console.WriteLine("Bark!");
- }
- }
- class Cat : Animal // Класът Котка имплементира Животно
- {
- public void MakeSound()
- {
- Console.WriteLine("Meow!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement