// interface interface Animal{void animalSound(); // interface method (does not have a body)void run(); // interface method (does not have a body)}
Example
interface IAnimal
{
void animalSound();
}
class Dog : IAnimal
{
public void animalSound()
{
Console.WriteLine("The dog says: woof woof");
}
}
class Program
{
static void Main(string[] args)
{
Dog myDog = new Dog();
myDog.animalSound();
}
}
=> output:
The dog says: woof woof