Created
July 27, 2019 19:00
-
-
Save MSDN-WhiteKnight/4bdaa799637b1d41dde8d1ce2d362ae8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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