Skip to content

Instantly share code, notes, and snippets.

@MSDN-WhiteKnight
Created July 27, 2019 19:00
Show Gist options
  • Save MSDN-WhiteKnight/4bdaa799637b1d41dde8d1ce2d362ae8 to your computer and use it in GitHub Desktop.
Save MSDN-WhiteKnight/4bdaa799637b1d41dde8d1ce2d362ae8 to your computer and use it in GitHub Desktop.
using System;
using System.Collections;
using System.Linq.Expressions;
using System.Reflection;
namespace ConsoleApplication1
{
class Program
{
public static object call(object[] args)
{
Console.WriteLine("call");
return 0;
}
static void Main(string[] args)
{
NewArrayExpression expr_arr = Expression.NewArrayInit(
typeof(object)
);
MethodCallExpression call_expr = Expression.Call(typeof(Program).GetMethod("call"), expr_arr);
var f_expr = Expression.Lambda<Action>(call_expr);
Action f = f_expr.Compile();
f();
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment