コード例 #1
0
    public static int Main(string[] args)
    {
        //Comments are what is printed out.
        var d1 = new D1();
        var d2 = new D2();

        d1.Foo <C1>();  //31
        Console.WriteLine();
        d1.Foo <C2>();  //31
        Console.WriteLine();
        //d2.Foo<C1>(); //Error constraint mismatch
        d2.Foo <C2>();  //421
        Console.WriteLine();
        B_base b_d2 = d2;

        b_d2.Foo <C1>();          //1
        Console.WriteLine();
        b_d2.Foo <C2>();          //1
        Console.WriteLine();
        return(0);
    }