tags:

views:

61

answers:

1

Is there anyway to determine if a value is passed as a reference, eg. x.Age or a specific value. eg. 20 like so.

value(x => x.Age)

or

value(x => 20)

Cheers

+4  A: 

If value() takes a Func<,> or other delegate type then you basically can't tell. The function has been compiled: at best, you can look at the IL using reflection and try to figure it out heuristically.

If value() takes an Expression, then you can walk the expression tree. This could be complicated in the general case, but for simple cases like yours, it would suffice to look for a MemberExpression versus a ConstantExpression.

itowlson