public static Dictionary<string, decimal?> DisplayNameModel<T>(T t)
{
Type type = typeof(T);
PropertyInfo[] properties = type.GetProperties();
Dictionary<string, decimal?> dic = new Dictionary<string, decimal?>();
foreach (var p in properties)
{
//display名字
var name = p.GetCustomAttribute<DisplayNameAttribute>().DisplayName;
//对应的值
var value = t.GetType().GetProperty(p.Name).GetValue(t, null);
dic.Add(name, Convert.ToDecimal(value));
}
return dic;
}
-
public static Dictionary<string, decimal?> DisplayNameModel<T>(T t)
-
-
-
PropertyInfo[] properties = type.GetProperties();
-
Dictionary<string, decimal?> dic = new Dictionary<string, decimal?>();
-
foreach (var p in properties)
-
-
-
var name = p.GetCustomAttribute<DisplayNameAttribute>().DisplayName;
-
-
var value = t.GetType().GetProperty(p.Name).GetValue(t, null);
-
dic.Add(name, Convert.ToDecimal(value));
-
-
-