Skip to content
Discussion options

You must be logged in to vote

It's complicated :-). Some historical context may be useful.

Expression trees were initially introduced in .NET Framework 3.5 with C# 3.0 and VB 9.0 as part of the LINQ feature set. There are two parts to it:

  1. An expression tree API, in System.Linq.Expressions.
  2. Language support to convert lambda expressions to Expression<TDelegate> (quotation).

For example:

Expression<Func<int, int>> f = x => x * 2;

is turned into

var x = Expression.Parameter(typeof(int), "x");
Expression<Func<int, int>> f = Expression.Lambda<Func<int, int>>(Expression.Multiply(x, Expression.Constant(2)), x);

With very few exceptions (multi-dimensional array initializers and assignment expressions come to mind), pretty m…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by YairHalberstadt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3296 on November 24, 2020 10:52.