[Wasm] Fix memory override in mono_wasm_add_assembly
[mono-project.git] / mcs / tests / test-394.cs
blob01c25f351267867e3b025a6d16da85fbeeb670f8
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 string MethodHandler (C c);
58 static string MethodSampleA (A value)
60 return value.Name;
63 static string MethodSampleB (B value)
65 return value.Name;
68 static string MethodSampleC (C value)
70 return value.Name + " " + value.Value;
73 public static void Main ()
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));