【发布时间】:2015-03-27 20:41:50
【问题描述】:
我的问题与this post (getting the object out of a memberexpression) 非常相似,但不同之处在于我需要从字段中获取它。
// how to get 1 from i?
int i = 1;
Expression<Func<int, int, bool>> a = (x1, x2) => x1 == i;
BinaryExpression x = (BinaryExpression)a.Body;
x.Right.//What now?
我不能像链接示例中那样使用 get type.getmember.getvalue,因为 i 是一个局部变量。那么如何提取字段或局部变量的值(不一定是我尝试提取的本地变量)?
【问题讨论】:
标签: c# linq-expressions