C#怎样获取object对象的属性值 ?下面就给出示例代码
///获取一个类指定的属性值
/// object对象
/// field 属性名称
public static object GetPropertyValue(object info, string field)
{
if (info == null) return null;
Type t = info.GetType();
IEnumerable property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi;
return property.First().GetValue(info, null);
}