运行 ❯
获取您
自己的 C#
服务器
×
更改方向
更改主题,深色/浅色
前往“空间”
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(); } } }
小猪说:wee wee