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);
在運行時分解表達式樹,并顯示以下字符串: