public static int Foo(int a, int b) { return a + b; }
public static void Bar(string message) { Console.WriteLine("hello world"); }
public static System.Object ToObject<TResult, T1, T2>(Func<TResult, T1, T2> func) {
return func as System.Object;
public static System.Object ToObject<T1>(Action<T1> func) {
return func as System.Object;
public static void Main()
var foo = ToObject<int, int, int>(Foo);
var bar = ToObject<string>(Bar);
var baz = foo as Func<int, int, int>;
Console.WriteLine(baz(1, 2));