public static class Program
public static void Main()
MethodInfo methodToInvoke = typeof(MyClass).GetMethod(
new System.Type[] { typeof(BaseClass) });
var result = methodToInvoke
.Invoke(new MyClass(), new object[] { new BaseClass() });
Console.WriteLine(result);
MethodInfo methodToInvoke2 = typeof(MyClass).GetMethod(
new System.Type[] { typeof(Int32[]) });
var result2 = methodToInvoke2
.Invoke(new MyClass(), new object[] { new int[] { 1 } });
Console.WriteLine(result2);
MethodInfo methodToInvoke3 = typeof(MyClass).GetMethod(
new System.Type[] { typeof(MoreDerivedClass) });
var result3 = methodToInvoke3
.Invoke(new MyClass(), new object[] { new MoreDerivedClass() });
Console.WriteLine(result3);
MethodInfo methodToInvoke4 = typeof(MyClass).GetMethod(
new System.Type[] { typeof(MyDelegate) });
var result4 = methodToInvoke4
.Invoke(new MyClass(), new object[] { null });
Console.WriteLine(result4);
MethodInfo methodToInvoke5 = typeof(MyClass).GetMethod(
new System.Type[] { typeof(MyImplementation) });
var result5 = methodToInvoke5
.Invoke(new MyClass(), new object[] { null });
Console.WriteLine(result5);
public static string myFunc(BaseClass bc) {
public static string myFunc(DerivedClass dc) {
public static string myFunc(MoreDerivedClass dc) {
return "MoreDerivedClass";
public static string myFunc(params int[] i)
public static string myFunc(MyDelegate d)
public static string myFunc(MyImplementation i)
return "interface implementations";
public interface IMyInterface {}
public class MyImplementation : IMyInterface {}
public delegate void MyDelegate(string x);
public class BaseClass { }
public class DerivedClass : BaseClass { }
public class MoreDerivedClass : DerivedClass {}