Create Expression Trees with a lambda expression

suggest change

Following is most basic expression tree that is created by lambda.

Expression<Func<int, bool>> lambda = num => num == 42;

To create expression trees ‘by hand’, one should use Expression class.

Expression above would be equivalent to:

ParameterExpression parameter = Expression.Parameter(typeof(int), "num"); // num argument
ConstantExpression constant = Expression.Constant(42, typeof(int)); // 42 constant
BinaryExpression equality = Expression.Equals(parameter, constant); // equality of two expressions (num == 42)
Expression<Func<int, bool>> lambda = Expression.Lambda<Func<int, bool>>(equality, parameter);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Expression Trees:
* Create Expression Trees with a lambda expression

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
89 Expression Trees
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script