Given a type ExpressionType.MemberAccess, how do i get the field value?

前端 未结 2 599
终归单人心
终归单人心 2021-01-31 03:05

I am parsing an Expression Tree. Given a NodeType of ExpressionType.MemberAccess, how do I get the value of that Field?

From C# MSDN docs: MemberAccess is A node that

2条回答
  •  悲哀的现实
    2021-01-31 04:00

    thank you so so much to Marc Gravell above. I really appreciated his help.

    It turns out, in my case. the problem can be solved via:

    object value = Expression.Lambda(expBody.Right).Compile().DynamicInvoke();
    

    Thanks again Mark!

提交回复
热议问题