日期:2014-05-17  浏览次数:21549 次

C#如何获取object对象的属性值

        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);

        } 
?