- Arithmetic Operations
- Assign Expression
- Comparison Expression
- Conditional Expression
- Exception Expression
- Iteration Expression
- Jump Expression
- Logical Expression
- Member Expression
- Operators Expression
Expression Tree Tutorial Field Expression
You can build an expression tree which contains accessing a given field by its name using Expression.Field
method. For example, you have the following code.
TestClass obj = new TestClass();
Console.WriteLine(obj.myField);
Here is the code that is required to build the same functionality using expression tree.
Expression fieldExpr = Expression.Field( Expression.Constant(obj), "myField" ); Console.WriteLine(Expression.Lambda<Func<int>>(fieldExpr).Compile()());