如何去遍历对象中的所有的属性值

 //本函数是使用了反射来实现访问对象的属性值的函数
//using System.Reflection;
 private void GetObjectPropertyValue(clsUser user)
{
        Type t = user.GetType();
        foreach (PropertyInfo pi  in t.GetProperties())
        {
            Response.Write( pi.Name + "---" + pi.GetValue(user,null) + "<br>");
        }
}
      
  

posted @ 2008-03-26 18:01  zijinguang  阅读(989)  评论(0编辑  收藏  举报