#1,174 – Assigning a Lambda Expression to an Expression Tree

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;
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #1,174 – Assigning a Lambda Expression to an Expression Tree

  1. Pingback: Dew Drop – September 3, 2014 (#1847) | Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: