抽象工厂,名字就告诉你是抽象的了.上代码. public interface BMW { public void Drive(); } public class BMW730 : BMW { public override void Drive() { Console.WriteLine("BMW 730 Run"); } } public class BMWX6 : BMW { public override void Drive() { Console.WriteLine(&quo…
简单工厂,代码: public interface ISpeak { public void Say(); } public class Hello : ISpeak { public void Say() { //throw new NotImplementedException(); Console.WriteLine("Hello"); } } public class Bye : ISpeak { public void Say() { Console.WriteLine(&q…