C# get propery name and value using expression code example
Example: public class NameOf { public static String nameof(Expression> name) { MemberExpression expressionBody = (MemberExpression)name.Body; return expressionBody.Member.Name; } }
public class NameOf
{
public static String nameof<T>(Expression<Func<T>> name)
{
MemberExpression expressionBody = (MemberExpression)name.Body;
return expressionBody.Member.Name;
}
}