C#面向对象基础--接口
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace InterFaceTest { //声明接口 public interface ISleep { void sleep(); } //实现接口 public class People : ISleep { public void sleep() { Console.WriteLine("人睡觉"); } } //实现接口 public class Dog : ISleep { public void sleep() { Console.WriteLine("狗睡觉"); } } class Program { static void Main(string[] args) { People p = new People(); p.sleep(); } } }