获取属性列表blic static 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 ();
}
Type t = typeof(Sit_showcase); System.Reflection.PropertyInfo[] properties = t.GetProperties(); foreach (System.Reflection.PropertyInfo info in properties) { Response.Write("name=" + info.Name + ";" + "type=" + info.PropertyType.Name + ";value=" + GetObjectPropertyValue<Sit_showcase>(showcase, info.Name) + "<br />"); }