//program.cs
class Program
{
static void Main(string[] args)
{
Dog oDog = new Dog();
Console.WriteLine(oDog.Cry());
Cat oCat = new Cat();
Console.WriteLine(oCat.Cry());
Console.ReadKey();
}
//IAnimal.cs
interface IAnimal
{
string Cry();
}
//Dog.cs
class Dog : IAnimal
{
public string Cry()
{
return "Woof!";
}
}
//Cat.cs
class Cat : IAnimal
{
public string Cry()
{
return "Meow!";
}
}
So, I did the above small program to demonstrate myself an example of interface. I wanted to confirm whether it is correct and are there anything more I should know about interfaces other than it is important to implement Polymorphism and multiple inheritance. Any suggestion is appreciated. Thanks.