Template Method Pattern : Template Pattern « Design Patterns « C# / CSharp Tutorial






using System;

  public abstract class Window
  {
    public abstract void  PositionLabel();
      
    public void SetupWindowFace()
    {
      this.PositionLabel();
    }
    public Window(){;}
    
  }
  public class WindowDeluxe: Window
  {
    public override void  PositionLabel()
    {Console.WriteLine("center.");}
    
    public WindowDeluxe(){;}
  }
  public class WindowStandard:Window
  {
    public override void PositionLabel(){;}
    public WindowStandard()  {;}
    
  }

  class Client
  {
    static void Main(string[] args)
    {
      Window delWindow = new WindowDeluxe();
      delWindow.SetupWindowFace();

      Window stdWindow = new WindowStandard();
      stdWindow.SetupWindowFace();
    }
  }








28.9.Template Pattern
28.9.1.Template Method Pattern