This is mot likely a duplicate, but I couldn’t find a proper question.
I want to get "MyClass.Name" from () => MyClass.Name. How do I define the method parameter and how do I convert the expression to a string?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is an
Expression<Func<string>>, so you could have:or
however, note that the syntax
MyClass.Namerefers to a static property; if you want an instance property you might need something more like anExpression<Func<MyClass,string>>– for example:As for implementation; in this simple case, we can expect the
Bodyto be aMemberExpression, so:However, it is more complex in the general case. This will also work if we use the static member: