Design Pattern 10-template

using System;

namespace Pattern
{
 /// <summary>
 /// Summary description for Class1.
 /// </summary>
 public abstract class template
 {
  public template()
  {
   //
   // TODO: Add constructor logic here
   //
  }
  public abstract string getstring();
  public void act()
  {
   string a=getstring();
   System.Console.WriteLine( a+"****"+a);
  }
 }

 public class temp1 :template
 {
  private string a;
  public temp1(string temp)
  {
           a=temp;
  }
  public override string getstring()
  {
   return a;
  }

 }
}



   // 模板模式
//   template a=new  temp1("kkk");
//   a.act();
//    a=new  temp1("XXX");
//   a.act();

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章