1、通过属性字段获得属性的值
//根据属性字段获得属性值
public string GetObjectPropertyValue<T>(T t, string propertyname)
{
Type type = typeof(T);
PropertyInfo property = type.GetProperty(propertyname);
if (property == null) return string.Empty;
object o = property.GetValue(t, null);
if (o == null) return string.Empty;
return o.ToString();
}
1259

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



