首页 > 代码库 > DesignPattern_Behavioral_TemplateMethod

DesignPattern_Behavioral_TemplateMethod

void Main(){    Template ta = new ProductA();    Template tb = new ProductB();    ta.Show();    tb.Show();}abstract class Template{    public void Show(){        string.Format("Template->{0}",GetName()).Dump();    }    protected abstract string GetName();}class ProductA:Template{    protected override string GetName(){return "A";}}class ProductB:Template{    protected override string GetName(){return "B";}}

 

DesignPattern_Behavioral_TemplateMethod