获取List<object>中对象的属性值
1 List<object> ls = new List<object>(); 2 ls.Add(new{id=1,name="sqm"}); 3 ls.Add(new{id=2,name="sqm2"}); 4 5 string id1 = ls[0].GetType().GetProperty("id").GetValue(ls[0],null).ToString(); 6 string name1 = ls[0].GetType().GetProperty("name").GetValue(ls[0],null).ToString(); 7 8 string id2 = ls[1].GetType().GetProperty("id").GetValue(ls[1],null).ToString(); 9 string name2 = ls[1].GetType().GetProperty("name").GetValue(ls[1],null).ToString();