在开发中会遇到一个对象有大量的属性,这时候需要遍历。
Studentdesc desc = new Studentdesc() foreach (PropertyInfo p in desc.GetType().GetProperties()) { Console.WriteLine("Name:{0} Value:{1}", p.Name, p.GetValue(desc)); }
这样,就可以得到信息喽。
在开发中会遇到一个对象有大量的属性,这时候需要遍历。
Studentdesc desc = new Studentdesc() foreach (PropertyInfo p in desc.GetType().GetProperties()) { Console.WriteLine("Name:{0} Value:{1}", p.Name, p.GetValue(desc)); }
这样,就可以得到信息喽。
转载于:https://www.cnblogs.com/QQ544952425/archive/2012/11/01/2750096.html