using System.Linq.Expressions;
using System.Collections;
using System.Collections.Generic;
public static void Main()
Console.WriteLine("****************** C# Equivalent Output **************************\n\n");
Console.WriteLine("num is greater than 10");
Console.WriteLine("num is less than or equan to 10");
Console.WriteLine("\n\n***************** Expression Tree Output **************************\n\n");
var testCondition = Expression.Constant(num > 10);
var ifTrueBlock = WriteLineExpression("num is greater than 10");
var ifFalseBlock = WriteLineExpression("num is less than or equal to 10");
var ifThenElseExpr = Expression.IfThenElse(
Expression.Lambda<Action>(ifThenElseExpr).Compile()();
public static Expression WriteLineExpression(string s)
return Expression.Call(null,
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(String) }),