List<object> ls = new List<object>();
ls.Add(new{id=1,name="sqm"});
ls.Add(new{id=2,name="sqm2"});
int id1 = ls[0].GetType().GetProperty("id").GetValue(ls[0],null).ToString();
string name1 = ls[0].GetType().GetProperty("name").GetValue(ls[0],null).ToString();
int id2 = ls[1].GetType().GetProperty("id").GetValue(ls[1],null).ToString();
string name2 = ls[1].GetType().GetProperty("name").GetValue(ls[1],null).ToString();
C# list<object> 获取属性值
最新推荐文章于 2024-05-14 08:50:02 发布