1

I have a pure theoretical question.

When do you use Expression<TDelegate>, and when do you use just the TDelegate?

Example:

Func<string> myDelegate = () => "Hello World";
Expression<Func<string>> myExpression = () => "Hello World";

Both compile into usable code, and I can call both with the following:

var delegateResult = myDelegate();
var expressionResult = myExpression.Compile()();

So my question is.. What is the use of Expression<TDelegate> and what would be a situation for preferring using it over the TDelegate directly?

Arcturus
  • 26,677
  • 10
  • 92
  • 107
  • 5
    For example, whenever you'd like to inspect the AST inside the expression, you'd have to use the `Expression`, regular `Func` doesn't have such capability. – Patryk Ćwiek Mar 26 '14 at 12:42

0 Answers0