using System.Linq.Expressions;
using System.Collections;
using System.Collections.Generic;
public static void Main()
Console.WriteLine("****************** C# Equivalent Output **************************\n\n");
Func<int, bool> myFunc = (x) =>
Console.WriteLine(myFunc(5));
Console.WriteLine("\n\n***************** Expression Tree Output **************************\n\n");
LabelTarget returnTarget = Expression.Label(typeof(bool));
ParameterExpression para = Expression.Parameter(typeof(int), "intvalue");
Expression test = Expression.Equal(para, Expression.Constant(5));
Expression iftrue = Expression.Return(returnTarget, Expression.Constant(true));
Expression iffalse = Expression.Return(returnTarget, Expression.Constant(false));
var ex = Expression.Block(
Expression.IfThenElse(test, iftrue, iffalse),
Expression.Label(returnTarget, Expression.Constant(false)));
var compiled = Expression.Lambda<Func<int, bool>>(
new ParameterExpression[] { para }
Console.WriteLine(compiled(5));