[corlib] Fix a few NSLogWriter issues. (#13799)
[mono-project.git] / mcs / tests / test-395.cs
blobf8c570f5cd12911d8c51f7c984b3533cabe0fbe1
1 // Compiler options: -langversion:default
2 //
3 // Test for contravariance support in delegates
4 //
6 using System;
8 public class A {
9 protected string name;
11 public A (string name)
13 this.name = "A::" + name;
16 public A ()
20 public string Name {
21 get {
22 return name;
27 public class B : A {
28 public B (string name)
30 this.name = "B::" + name;
33 public B ()
38 public class C : B {
39 string value;
41 public C (string name, string value)
43 this.name = "C::" + name;
44 this.value = value;
47 public string Value {
48 get {
49 return value;
54 public class Tester {
56 delegate void MethodHandler (C c1, C c2, C c3);
58 static void MethodSample (B b, A a, C c)
60 Console.WriteLine ("b = {0}", b.Name);
61 Console.WriteLine ("a = {0}", a.Name);
62 Console.WriteLine ("c = {0}, {1}", c.Name, c.Value);
65 public static void Main ()
67 MethodHandler mh = MethodSample;
69 C a = new C ("Hello", "hello");
70 C b = new C ("World", "world");
71 C c = new C ("!", "!!!");
73 mh (b, a, c);