List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };

 

            //这里用foreach时,会出错,主要是foreach在检索的时候,它的数组不能变 for循环的就可以

            //foreach (int i in list)

            //{

            //    MessageBox.Show(i.ToString());

            //    list.Remove(i);

            //}

 

            for (int j = 0; j < list.Count; j++)

            {

                MessageBox.Show(list[j].ToString());

                list.Remove(list[j]);

                j--;

            }

相关文章:

  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案