Compiled Expression Tree : Expressions « LINQ « C# / CSharp Tutorial






using System;
using System.ComponentModel;
using System.Linq.Expressions;

    class CompiledExpressionTree
    {
        static void Main()
        {
            Expression firstArg = Expression.Constant(2);
            Expression secondArg = Expression.Constant(3);
            Expression add = Expression.Add(firstArg, secondArg);

            Func<int> compiled = Expression.Lambda<Func<int>>(add).Compile();
            Console.WriteLine(compiled());
        }
    }








22.15.Expressions
22.15.1.Cast to BinaryExpression
22.15.2.Cast to ParameterExpression
22.15.3.Compiled Expression Tree
22.15.4.Expression Tree
22.15.5.Lambda Expression To Expression Tree
22.15.6.Lambda Expression With Parameters To Expression Tree
22.15.7.Expression Tree