Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / test-395.cs
1 // Compiler options: -langversion:default
2 //
3 // Test for contravariance support in delegates
4 //
5
6 using System;
7
8  public class A {
9          protected string name;
10          
11          public A (string name)
12          {
13                  this.name = "A::" + name;
14          }
15
16          public A ()
17          {
18          }
19
20          public string Name {
21                  get {
22                          return name;
23                  }
24          }
25  }
26
27  public class B : A {
28          public B (string name)
29          {
30                  this.name = "B::" + name;
31          }
32
33          public B ()
34          {
35          }
36  }
37
38  public class C : B {
39          string value;
40
41          public C (string name, string value)
42          {
43                  this.name = "C::" + name;
44                  this.value = value;
45          }
46
47          public string Value {
48                  get {
49                          return value;
50                  }
51          }
52  }
53
54  public class Tester {
55
56          delegate void MethodHandler (C c1, C c2, C c3);
57
58          static void MethodSample (B b, A a, C c)
59          {
60                  Console.WriteLine ("b = {0}", b.Name);
61                  Console.WriteLine ("a = {0}", a.Name);
62                  Console.WriteLine ("c = {0}, {1}", c.Name, c.Value);
63          }
64
65          public static void Main ()
66          {
67                  MethodHandler mh = MethodSample;
68
69                  C a = new C ("Hello", "hello");
70                  C b = new C ("World", "world");
71                  C c = new C ("!", "!!!");
72
73                  mh (b, a, c);
74          }
75         
76  }
77