Пример #1
0
        static void Main(string[] args)
        {
            AbstractClass abstractClass = new ConcreteClass1();

            abstractClass.TemplateMethod();
            abstractClass = new ConcreteClass2();
            abstractClass.TemplateMethod();
        }
Пример #2
0
        static void Main(string[] args)
        {
            AbstractClass abstractClass1 = new ConcreteClass1();
            AbstractClass abstractClass2 = new ConcreteClass2();

            abstractClass1.Operate();
            Console.WriteLine();
            abstractClass2.Operate();
        }
Пример #3
0
        static void Main(string[] args)
        {
            AbstractClass class1 = new ConcreteClass1();
            AbstractClass class2 = new ConcreteClass2();

            //调用模版方法
            class1.templateMethod();
            class2.templateMethod();
            Console.ReadLine();
        }
Пример #4
0
        static void Main(string[] args)
        {
            AbstractClass concreteclass1 = new ConcreteClass1();

            concreteclass1.TemplateMethod();

            AbstractClass concreteclass2 = new ConcreteClass2();

            concreteclass2.TemplateMethod();
        }
Пример #5
0
        static void Main(string[] args)
        {
            // use ConcreteClass1 operation to do TemplateMethod
            var concrete1 = new ConcreteClass1();

            concrete1.TemplateMethod();

            // use ConcreteClass2 operation to do TemplateMethod
            var concrete2 = new ConcreteClass2();

            concrete2.TemplateMethod();
        }