public static object GetPropertyValue(object info, string field)
{
if (info == null) return null;
Type t = info.GetType();
IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi;
return property.First().GetValue(info, null);
}
本文介绍了一个静态方法 GetPropertyValue,该方法用于从指定对象中获取特定字段的属性值。通过反射机制,此方法能够智能匹配并返回对象中对应字段的值。
3928

被折叠的 条评论
为什么被折叠?



