show your code, are you using foreach?

解决方案 »

  1.   

    Thanks.You're right.
    In statement ("foreach(DataRow row in DataSet.Tables[0].Rows)");
    There're so many statements if show here.
    实际上,我是用DataSet做DataGrid的数据源,然后会有一些编辑,这些编辑会保存到DataSet中的DataRow 中,更新没有问题,添加也可以,就是在删除的时候,我要检测删除的是哪一行,所以用foreach循环。然后异常出现了。
    很佩服你的推断能力。
      

  2.   

    don't use foreach when you need to modify the collection
      

  3.   

    Thank you very much.
    I write code like this:
    for(int i=0;;i++){
       if(){
         .....
         break;
       }
    }