static void Main(string[] args) { Factory[] factories =new Factory[2]; factories[0] = new Factory1(); factories[1] = new Factory2(); foreach (Factory factory in factories) { Product product = factory.Create(); Console.WriteLine(product.GetType().Name + " by " + factory.GetType().Name); } Console.ReadKey(); }
static void Main(string[] args) { Factory[] factories = new Factory[2]; factories[0] = new Factory1(); factories[1] = new Factory2(); foreach (Factory factory in factories) { Product product = factory.Create(); Console.WriteLine(product.GetType().Name + " by " + factory.GetType().Name); } Console.ReadKey(); }