I have this method:
public void DoSomething<T>(Expression<Func<T, object>> method) { }
If this method is called as follows:
DoSomething(c => c.SomeMethod(new TestObject()));
... how to get the value of the parameter that was passed to SomeMethod ()?
If the parameter is a value type, this works:
var methodCall = (MethodCallExpression)method.Body; var parameterValue = ((ConstantExpression)methodCall.Arguments[0]).Value;
However, when I pass the reference type, the Call.Arguments [0] method is MemberExpression, and I cannot figure out how to write code to get the value from it.
source share