interface Animal
{
void Speak();
}
interface Mammal : Animal
{
void Walk();
}
class Dog : Mammal
{
void Animal.Speak()
{
Console.WriteLine("Woof!");
}
void Mammal.Walk()
{
Console.WriteLine("The dog is walking.");
}
public void Eat()
{
Console.WriteLine("The dog is eating.");
}
}
class Program
{
static void Main(string[] args)
{
Dog d = new Dog();
d.Eat();
Animal a = d;
a.Speak();
Mammal m = d;
m.Walk();
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter