Run ❯
Get your
own
website
×
Change Orientation
using System; namespace MyApplication { // Interface interface IAnimal { void animalSound(); // interface method (does not have a body) } // Pig "implements" the IAnimal interface class Pig : IAnimal { public void animalSound() { // The body of animalSound() is provided here Console.WriteLine("The pig says: wee wee"); } } class Program { static void Main(string[] args) { Pig myPig = new Pig(); // Create a Pig object myPig.animalSound(); } } }
The pig says: wee wee