C#获取某个对象的属性值

/// 
/// 获取某个对象中的属性值
/// 
/// 
/// 
/// 
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);
}

你可能感兴趣的:(C#,C#获取对象的属性值)