接口隔离原则
// 学习接口隔离原则 using System; namespace console { class Program { static void Main(string[] args) { Person p = new Person(new Car()); Person p1 = new Person(new Tank()); } } interface ICanRun{ void run(); } interface ICanFire{ void fire(); } interface ITank{ void run(); void fire(); } class Person{ public Person(ICanRun icanrun){ icanrun.run(); } } class Car:ICanRun{ public void run(){ Console.WriteLine("开车了"); } } class Tank :ICanRun,ICanFire{ public void run(){ Console.WriteLine("坦克开车了"); } public void fire(){ Console.WriteLine("开炮了"); } } }