CSharp · Console
using System;
using System.Linq.Expressions;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
Console.WriteLine("****************** C# Equivalent Output **************************\n\n");
string text = "This is simple text.";
Console.WriteLine(text.ToUpper());
Console.WriteLine("\n\n***************** Expression Tree Output **************************\n\n");
Expression callExpr = Expression.Call(
Expression.Constant(text), typeof(String).GetMethod("ToUpper", new Type[] { }));
// The following statement first creates an expression tree,
// then compiles it and then executes it.
Console.WriteLine(Expression.Lambda<Func<String>>(callExpr).Compile()());
}
}