using System.Linq.Expressions;
using System.Collections;
using System.Collections.Generic;
public static void Main()
Console.WriteLine("****************** C# Equivalent Output **************************\n\n");
Console.WriteLine(cValue);
Console.WriteLine("\n\n***************** Expression Tree Output **************************\n\n");
LabelTarget breakLabel = Expression.Label();
LabelTarget continueLabel = Expression.Label();
Expression continueExpr = Expression.Continue(continueLabel);
ParameterExpression count = Expression.Parameter(typeof(int));
var ifTrueBlock = continueExpr;
var ifFalseBlock = Expression.Call(
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) }),
var nestedIfThenElseExpr = Expression.IfThenElse(
Expression.Equal(count, Expression.Constant(3)),
var ifThenElseExpr = Expression.IfThenElse(
Expression.LessThan(count, Expression.Constant(5)),
Expression.Break(breakLabel, count)
var block = Expression.Block(Expression.PostIncrementAssign(count), ifThenElseExpr);
Expression loopExpr = Expression.Loop(block,
Expression.Lambda<Action<int>>(loopExpr, count).Compile()(0);