interface 关键字 声明接口
接口中的成员默认都是public
能力不一样的时候适合用接口
using System; using System.Collections; using System.Collections.Generic; namespace Dome { class dom { static void Main(string[] args) { play iplay = new student(); iplay.iplay(); Console.WriteLine(); Console.ReadKey(); } } public class person {//父类 public void sayhello() { Console.WriteLine("我是人类"); } } public class student:person,play {//继承父类person和接口play 必须实现接口中的成员 public void hello() { Console.WriteLine("我是学生"); } public void iplay() { Console.WriteLine("实现接口"); } } interface play {//接口中的成员默认是public void iplay(); } }
原文:http://www.cnblogs.com/syzly/p/6659904.html