2 using System
.Reflection
;
6 public static int Main (string[] args
)
9 Derived d
= new Derived ();
10 // ldvirtftn Base::Foo
12 Del1 b
= new Del1 (d
.Foo
);
13 var mi
= typeof (Del1
).GetMethod ("Invoke");
16 // should call Derived.Foo not Base.Foo
17 var r
= (int) mi
.Invoke (b
, new object[] {"abcd"}
);
23 public delegate int Del1 (string s
);
24 public delegate int Del2 (string s
);
28 public virtual int Foo (string s
)
30 Console
.WriteLine ("Base.Foo called. Bad");
35 public class Derived
: Base
37 public override int Foo (string s
)
39 Console
.WriteLine ("Derived.Foo called. Good");