list.RemoveAt(index)的时候老是报错,说集合的大小是固定的,用remove也是,请问这是怎么回事。

解决方案 »

  1.   

    需要把前后代码贴出来,都不知道list是什么类型的
      

  2.   

    IList<AndroidTools2WebService.ListStorage> webListStorage = new List<AndroidTools2WebService.ListStorage>();  //这是定义  for (int i = 0; i < webListStorage.Count; i++)
                                {
                                    if (webListStorage[i] == null)
                                        continue;
                                    string tempId = webListStorage[i].ResourceId.ToString();
                                    if (tempId.Equals(id))
                                    {
                                        //移除控件中的选中项
                                        lvImageSequence.Items.RemoveByKey(id);
                                                                         
                                        
                                        int a = webListStorage.IndexOf(webListStorage[i]);                                    //webListStorage = tempList;                                 
                                        webListStorage.RemoveAt(a);
                                       
                                        break;
                                    }
                                }
                            }
                        }
                    }
    这是后台代码
      

  3.   

    应该是不要在遍历的时候删除,,, 你可以记下key的集合 然后慢慢删吧、