Updated with review feedback.
[mono.git] / mcs / tests / gtest-optional-13.cs
1 using System;
2
3 class A
4 {
5         public virtual int Foo (int i)
6         {
7                 return i;
8         }
9         
10         public virtual int Foo2 (int i = 99)
11         {
12                 return i;
13         }
14
15         public virtual int this[string s, int arg] {
16                 get {
17                         return arg;
18                 }
19         }
20 }
21
22 class B : A
23 {
24         public override int Foo (int i2 = 4)
25         {
26                 return i2 + 1;
27         }
28         
29         public new int Foo2 (int i)
30         {
31                 return 77;
32         }
33
34         public override int this[string s, int arg2 = 9] {
35                 get {
36                         return arg2 + 1;
37                 }
38         }
39 }
40
41 class C
42 {
43         public static int Main ()
44         {
45                 B b = new B ();
46                 int i = b.Foo ();
47                 if (i != 5)
48                         return 1;
49
50                 i = b.Foo (i2: 3);
51                 if (i != 4)
52                         return 2;
53
54                 i = b["a"];
55                 if (i != 10)
56                         return 3;
57
58                 i = b["a", arg2: 20];
59                 if (i != 21)
60                         return 4;
61                 
62                 i = b.Foo2 ();
63                 if (i != 99)
64                         return 5;
65
66                 i = b.Foo2 (i : 8);
67                 if (i != 77)
68                         return 6;
69                 
70                 Console.WriteLine ("ok");
71                 return 0;
72         }
73 }