C#遍历匿名对象的所有属性、value
Object obj = new { name="admin",age=123 ,pwd="123" }; //遍历匿名对象 foreach (System.Reflection.PropertyInfo p in obj.GetType().GetProperties()) { Console.WriteLine("name:{0},value:{1}",p.Name,p.GetValue(obj)); }
Object obj = new { name="admin",age=123 ,pwd="123" }; //遍历匿名对象 foreach (System.Reflection.PropertyInfo p in obj.GetType().GetProperties()) { Console.WriteLine("name:{0},value:{1}",p.Name,p.GetValue(obj)); }