0

I understand the result and how to execute the compiled expression but why bother doing it?

  // Lambda expression as data in the form of an expression tree.`
  System.Linq.Expressions.Expression<Func<int, bool>> expr = i => i < 5;
// Compile the expression tree into executable code.
Func<int, bool> deleg = expr.Compile();
// Invoke the method and print the output.
Console.WriteLine("deleg(4) = {0}", deleg(4));

/*  This code produces the following output:

   deleg(4) = True
*/

`

T McKeown
  • 12,971
  • 1
  • 25
  • 32
  • How else would you be able to get a delegate which can be called as you can’t call an expression? – ckuri Feb 28 '19 at 19:14
  • well I don't use expressions, I only use lambda... so trying to figure out why I would use expression over lambda. – T McKeown Feb 28 '19 at 22:26

0 Answers0