3、tor。抽象产品(Product)角色:工厂方法模式所创建的对象的超类型,也就是产品对象的共同父类或共同拥有的接口。在上图中,这个角色是Light。具体产品(ConcreteProduct)角色:这个角色实现了抽象产品角色所定义的接口。某具体产品有专门的具体工厂创建,它们之间往往一一对应。三、 程序举例:using System;public abstract class Light{ public abstract void TurnOn(); public abstract void TurnOff()
4、;}public class BulbLight : Light{ public override void TurnOn() { Console.WriteLine("Bulb Light is Turned on"); } public override void TurnOff() { Console.WriteLine("Bulb Light is Turned off"); }}public class TubeLight : Light{ public override void Tur
5、nOn() { Console.WriteLine("Tube Light is Turned on"); } public override void TurnOff() { Console.WriteLine("Tube Light is Turned off"); }}public abstract class Creator{ public abstract Light factory();}public class BulbCreator : Creator{ public overr
6、ide Light factory() { return new BulbLight(); }}public class TubeCreator : Creator{ public override Light factory() { return new TubeLight(); }}public class Client{ public static void Main() { Creator c1 = new BulbCreator(); Creator c2 = new