bool isSmall = f(2); // isSmall is now true
变量 e 是对表达式树的引用,不可直接执行:
bool isSmall = e(2); // compile error, expressions == data
Expression filter = n => n < 5; BinaryExpression body = (BinaryExpression)filter.Body; ParameterExpression left = (ParameterExpression)body.Left; ConstantExpression right = (ConstantExpression)body.Right; Console.WriteLine("{0} {1} {2}", left.Name, body.NodeType, right.Value);
在运行时分解表达式树,并显示以下字符串: