1 // Compiler options: -langversion:default
3 // Test for contravariance support in delegates
11 public A (string name
)
13 this.name
= "A::" + name
;
28 public B (string name
)
30 this.name
= "B::" + name
;
41 public C (string name
, string value)
43 this.name
= "C::" + name
;
56 delegate string MethodHandler (C c
);
58 static string MethodSampleA (A
value)
63 static string MethodSampleB (B
value)
68 static string MethodSampleC (C
value)
70 return value.Name
+ " " + value.Value
;
75 MethodHandler da
= MethodSampleA
;
76 MethodHandler db
= MethodSampleB
;
77 MethodHandler dc
= MethodSampleC
;
79 C a
= new C ("Hello", "hello");
80 C b
= new C ("World", "world");
81 C c
= new C ("!", "!!!");
83 Console
.WriteLine (da (a
));
84 Console
.WriteLine (db (b
));
85 Console
.WriteLine (dc (c
));