ParameterExpression a = Expression.Parameter(typeof(int), "a");
ParameterExpression b = Expression.Parameter(typeof(int), "b");
BinaryExpression setA = Expression.Assign(a, Expression.Constant(21));
BinaryExpression setB = Expression.Assign(b, Expression.Constant(20));
// Console.Write("a == b:");
// Console.WriteLine(a == b);
MethodCallExpression call1 = Expression.Call(null,
typeof(Console).GetMethod("Write", new Type[] { typeof(string) }),
Expression.Constant("a == b:"));
MethodCallExpression call11 = Expression.Call(null,
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(bool) }),
// Console.Write("a < b :");
// Console.WriteLine(a < b);
MethodCallExpression call2 = Expression.Call(null,
typeof(Console).GetMethod("Write", new Type[] { typeof(string) }),
Expression.Constant("a < b :"));
MethodCallExpression call22 = Expression.Call(null,
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(bool) }),
Expression.LessThan(a, b));
// Console.Write("a > b :");
// Console.WriteLine(a > b);
MethodCallExpression call3 = Expression.Call(null,
typeof(Console).GetMethod("Write", new Type[] { typeof(string) }),
Expression.Constant("a > b :"));
MethodCallExpression call33 = Expression.Call(null,
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(bool) }),
Expression.GreaterThan(a, b));
BinaryExpression setAa = Expression.Assign(a, Expression.Constant(5));
BinaryExpression setBb = Expression.Assign(b, Expression.Constant(20));
// Console.Write("a <= b:");
// Console.WriteLine(a <= b);
MethodCallExpression call4 = Expression.Call(null,
typeof(Console).GetMethod("Write", new Type[] { typeof(string) }),
Expression.Constant("a <= b:"));
MethodCallExpression call44 = Expression.Call(null,
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(bool) }),
Expression.LessThanOrEqual(a, b));
// Console.Write("a >= b:");
// Console.WriteLine(b >= a);
MethodCallExpression call5 = Expression.Call(null,
typeof(Console).GetMethod("Write", new Type[] { typeof(string) }),
Expression.Constant("a >= b:"));
MethodCallExpression call55 = Expression.Call(null,
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(bool) }),
Expression.GreaterThanOrEqual(a, b));
BlockExpression block = Expression.Block(new ParameterExpression[] { a, b },
Expression<Action> lambda = Expression.Lambda<Action>(block);