Cast to BinaryExpression : Expressions « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Xml.Linq;

class Program
{
    static void Main(string[] args)
    {
        Func<int, int> func1 = x => x + 5;
        var result = func1(1);

        Expression<Func<int, int>> expression = func => func + 5;

        var originalDelegate = expression.Compile();
        var three = originalDelegate.Invoke(2);

        BinaryExpression operation = (BinaryExpression)expression.Body;
        Console.WriteLine(operation.NodeType);

    }

}








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