List<DIS_Model.Model_V_SYS_User_Info> list = v_userinfo.select(strWhere, PageSize, PageIndex);
List<Model_V_SYS_User_Info> students = new List<Model_V_SYS_User_Info>();
for (int i = 0; i < list.Count; i++)
{
model.User_Code = list[i].User_Code;
model.User_Email = list[i].User_Email;
model.User_Name = list[i].User_Name;
model.User_Address = list[i].User_Address;
model.ID = list[i].ID;
model.User_Phone = list[i].User_LinPhone;
students.Add(model);
}
我最后获得的值 都是最后一个相同的数据 ,怎么修改 求解 谢谢
------解决思路----------------------
for循环中,model应该每次创建一个新的,否则都是在用同一个model
------解决思路----------------------
for (int i = 0; i < list.Count; i++)
{
Model model = new Model();
model.User_Code = list[i].User_Code;
model.User_Email = list[i].User_Email;
model.User_Name = list[i].User_Name;
model.User_Address = list[i].User_Address;
model.ID = list[i].ID;
model.User_Phone = list[i].User_LinPhone;
students.Add(model);
}
Model model = new Model();