コード例 #1
0
    static void Main(string[] args)
    {
        DoSomething worker = new InsultMe();

        worker.whatToDo();
        worker = new InspireMe();
        worker.whatToDo();
    }
コード例 #2
0
    static void Main(string[] args)
    {
        DoSomething worker = new InsultMe();

        worker.whatToDo();
        worker = new InspireMe();
        worker.whatToDo();
        // In this case the base class method is invoked
        worker = new DoWhatBaseClassDoes();
        worker.whatToDo();
    }