家装设计师网站,.net网站开发简介,企业查询湖南,jsp 网站开发教程在对某个List进行遍历的同时#xff0c;需要对其中的Item进行删除操作。 会提示错误#xff1a;集合已修改#xff1b;可能无法执行枚举操作 Codeforeach (VirtualTDate vtDate in tempList){ if (vtDate.Date itemTime.Date) { tempList.Remove(vtDate); … 在对某个List进行遍历的同时需要对其中的Item进行删除操作。 会提示错误集合已修改可能无法执行枚举操作 Codeforeach (VirtualTDate vtDate in tempList){ if (vtDate.Date itemTime.Date) { tempList.Remove(vtDate); }} foreach循环中无法对List进行修改、删除操作。改用for循环可以执行 Codefor (int i 0; i tempList.Count; i){ if (tempList[i].Date.Equals(itemTime.Date)) { tempList.Remove(tempList[i]); }} 错误每删除一项游标应当减一 转载于:https://www.cnblogs.com/jerryshi/archive/2008/09/23/1296573.html