コード例 #1
0
    static void NestedClassesTest()
    {
        int res;

        //====================  Cases of nested classes  ====================//
        Outer1.Inner inner1 = new Outer1.Inner();
        res = inner1.Method(new Outer1());
        Console.WriteLine("Outer1.Inner.Method(new Outer1()) = " + res);
        if (res != 1)
        {
            Success = false;
        }

        Outer2.Inner <Outer2> inner2 = new Outer2.Inner <Outer2>();
        res = inner2.Method(new Outer2());
        Console.WriteLine("Outer2.Inner<Outer2>.Method(new Outer2()) = " + res);
        if (res != 1)
        {
            Success = false;
        }

        Outer3 <string> .Inner inner3 = new Outer3 <string> .Inner();

        res = inner3.Method(new Outer3 <string>());
        Console.WriteLine("Outer3<string>.Inner.Method(new Outer3<string>()) = " + res);
        if (res != 1)
        {
            Success = false;
        }

        Outer4 <string> .Inner <Outer4 <string> > inner4 = new Outer4 <string> .Inner <Outer4 <string> >();

        res = inner4.Method(new Outer4 <string>());
        Console.WriteLine("Outer4<string>.Inner<Outer4<string>>.Method(new Outer4<string>()) = " + res);
        if (res != 1)
        {
            Success = false;
        }
    }
コード例 #2
0
 public int Method(Outer3 <T> param)
 {
     return(++param.field);
 }