首页 > 代码库 > DesignPattern_Structural_Decorator

DesignPattern_Structural_Decorator

void Main(){    Component c1 = new Component();    Decorator da = new DecoratorA();    da.Decorate(c1);    Decorator db = new DecoratorB();    db.Decorate(da);    db.Show();}class Component{    public virtual void Show(){}}abstract class Decorator:Component{    protected Component component;    public void Decorate(Component c){component=c;}}class DecoratorA:Decorator{    public override void Show(){        component.Show();            }}class DecoratorB:Decorator{    public override void Show(){        component.Show();            }}

 

DesignPattern_Structural_Decorator