public abstract class Template
protected Template(string sender) {
protected abstract void PrintHeader(string recipient);
protected abstract void PrintContent(string content);
protected abstract void PrintFooter();
public void Print(string recipient, string content)
Console.WriteLine("------------------------------------");
Console.WriteLine("------------------------------------");
public class Memo : Template
public Memo(string sender) : base(sender) {
protected override void PrintHeader(string recipient)
Console.WriteLine("Dear {0},",recipient);
protected override void PrintContent(string content)
Console.WriteLine(content);
protected override void PrintFooter()
Console.WriteLine("From {0}",sender);
public static void Main()
Template t = new Memo("Jane");
t.Print("Peter","How are you?");