#1,174 – Assigning a Lambda Expression to an Expression Tree
September 3, 2014 1 Comment
You can assign a lambda expression to either an instance of a delegate type or to an expression tree based on a compatible delegate type. An expression tree is just an in-memory representation of an expression, encoding the expression as a tree. This allows you to interact with the expression as a data structure.
// Assign to delegate type Func<int, int> doubleMe = (i) => 2 * i; // Assign to expression tree // (using System.Linq.Expressions) Expression<Func<int, int>> doubleMeExpr = (i) => 2 * i;