例如,您的对象如下:
public class Test{
[Display("**hello world**")]
public string property{}
}
}
何我使用反射来获取我的属性(显示)的值,这将返回" hello world"
答案 0 :(得分:0)
我发现答案不知道它是否是最佳解决方案?
Type t = typeof(T);
var value = t.GetProperties().Select(f=>f.GetCustomAttribute<NamOfAttribute>()).DisplayName