static void Main(string[] args) { IFactory factory = new FactoryA();//需要产品B时更改类型即可**********推送修改 //IFactory factory = new FactoryA(); Product pA = factory.CreateProduct(); pA.Function(); Console.ReadLine(); }
static void Main(string[] args) { Factory factoryA = new FactoryA(); Product productA = factoryA.CreateProduct(); productA.Operation(); Factory factoryB = new FactoryB(); Product productB = factoryB.CreateProduct(); productB.Operation(); }