C
Colin Han
Hi, all,
If I write follow code in c# method. The IDE will compile it to a complex construct method of System.Linq.Expression.
Expression<Func<int>> ex = () => 10;
will be compile to:
Expression<Func<int>> ex = Expression.Lambda<Func<int>> (Expression.Literal(10))
It is so smart. I can travel in this expression tree. I can do some smart abilities on this design.
Now, I want write a console application. If user input follow string from console,
() => 10
I want make a LambdaExpression object and execute it in my context.
I can use CodeDom to compile some c# code to a dynamic assembly. But I have not found a utility to compile c# code to an expression object.
How to compile a c# Lambda expression to a Expression object? Help me. Thanks.
If I write follow code in c# method. The IDE will compile it to a complex construct method of System.Linq.Expression.
Expression<Func<int>> ex = () => 10;
will be compile to:
Expression<Func<int>> ex = Expression.Lambda<Func<int>> (Expression.Literal(10))
It is so smart. I can travel in this expression tree. I can do some smart abilities on this design.
Now, I want write a console application. If user input follow string from console,
() => 10
I want make a LambdaExpression object and execute it in my context.
I can use CodeDom to compile some c# code to a dynamic assembly. But I have not found a utility to compile c# code to an expression object.
How to compile a c# Lambda expression to a Expression object? Help me. Thanks.