工厂方法:创建型设计模式
用于创建复杂对象,同时该对象有不断变化需要扩展的可能性时, 使用工厂方法
1 public class HumanFactory : IFactory 2 { 3 public virtual IRace CreateRace() 4 { 5 return new Human(); 6 } 7 } 8 public class HumanFactoryAdvanced: HumanFactory 9 { 10 public override IRace CreateRace() 11 { 12 Console.WriteLine("123"); 13 return new Human(); 14 } 15 }