https://handcraftsman.wordpress.com/2008/11/11/how-to-get-c-property-names-without-magic-strings/

 

public static class ReflectionUtility
{
    public static string GetPropertyName<T>(Expression<Func<T>> expression)
    {
        MemberExpression body = (MemberExpression) expression.Body;
        return body.Member.Name;
    }
}
arrow
arrow
    文章標籤
    C# Reflection Property Name
    全站熱搜

    wings890109 發表在 痞客邦 留言(0) 人氣()