用了 Reflection反射机制,把一个对象的方法函数反射出来
using System.Reflection;
UsersModel = UsersBLL.GetModel(1);
foreach (PropertyInfo pi in UsersModel.GetType().GetProperties()) {
object v = pi.GetValue(UsersModel,null);
if (Convert.ToString(v) == "") v = "empty";
Response.Write(string.Format("{0}={1}<br/>", pi.Name, v));
}
.net 判断对象属性,.net 判断model对象属性是否赋值