[wasm] Improve virtualenv installation script (#18470)
[mono-project.git] / mono / tests / delegate18.cs
blob74dd755658bf4a18b49257196269cd642ec635b6
1 using System;
2 using System.Reflection;
4 internal class Program
6 public static int Main (string[] args)
8 // newobj Derived
9 Derived d = new Derived ();
10 // ldvirtftn Base::Foo
11 // newobj Del1::.ctor
12 Del1 b = new Del1 (d.Foo);
13 var mi = typeof (Del1).GetMethod ("Invoke");
14 if (mi is null)
15 return 2;
16 // should call Derived.Foo not Base.Foo
17 var r = (int) mi.Invoke (b, new object[] {"abcd"});
18 return r;
23 public delegate int Del1 (string s);
24 public delegate int Del2 (string s);
26 public class Base
28 public virtual int Foo (string s)
30 Console.WriteLine ("Base.Foo called. Bad");
31 return 1;
35 public class Derived : Base
37 public override int Foo (string s)
39 Console.WriteLine ("Derived.Foo called. Good");
40 return 0;