Type entityType = typeof(T); //T泛型
//通过属性名获取属性值 “CenterCode”属性名称
PropertyInfo proInfo = entityType.GetProperty("CenterCode");
var result = proInfo.GetValue(t);
proInfo.SetValue(t,3);
result = proInfo.GetValue(t);
Console.WriteLine(result);
c# 泛型通过反射获取属性值和修改属性值
最新推荐文章于 2024-07-18 16:22:57 发布