C#クイズ

実行結果を予想してください。答えは後日。

using System;

public class Program
{
    public static void Main()
    {
        Base b = new Derived();
        Console.WriteLine( b.Method( "dummy" ) );    // (1)

        Derived d = new Derived();
        Console.WriteLine( d.Method( "dummy" ) );    // (2)

        Hoge hoge = new Hoge();
        Console.WriteLine( hoge.Method( "dummy" ) ); // (3)

        Console.ReadKey();
    }
}

public class Base
{
    public virtual string Method( string s )
    {
        return "Base.Method(string)";
    }
}

public class Derived : Base
{
    public override string Method( string s )
    {
        return "Derived.Method(string)";
    }

    public virtual string Method( object o )
    {
        return "Derived.Method(object)";
    }
}

public class Hoge
{
    public string Method( string s )
    {
        return "Hoge.Method(string)";
    }

    public string Method( object o )
    {
        return "Hoge.Method(object)";
    }
}