Fork me on GitHub

c# 获得变量名称

 string GetVariableName<T>(Expression<Func<T>> expr)
        {
            var body = (MemberExpression)expr.Body;

            return body.Member.Name;
        } 

//调用 

GetVariableName(() => qtck_nMax)

 

posted @ 2020-09-11 15:18  HelloLLLLL  阅读(609)  评论(0编辑  收藏  举报