摘要: 反射案例1:DataRow dr = DAL.GetDataRow(); //从数据库取得一条记录 Employee e =new Employee();//实例化一个对象(可以为实体) System.Reflection.PropertyInfo[] ps = e.GetType().GetProperties();//取得对象的所有属性 foreach(System.Reflection.PropertyInfo p in ps) { p.SetValue(e, Convert.ChangeType(dr[p.Name], p.PropertyType), null);//循环附值 }这样 阅读全文
posted @ 2011-08-22 23:11 cntom 阅读(218) 评论(0) 推荐(0) 编辑