在学习期间,将写内容过程中比较重要的内容记录起来,下面内容是关于C#从ArrayList中删除对象的内容,希望能对各朋友有好处。

ArrayList alcollect = new ArrayList();


string str = "learn csharp";
alcollect.Add(str);
alcollecti.Remove(str);





通过RemoveAt方法根据索引号删除对象


ArrayList alcollect = new ArrayList();

alcollect.RemoveAt(0);





RemoveRange方法根据索引范围删除对象


ArrayList alcollect = new ArrayList();

alcollect.RemoveRange(0, 4);





Clear方法直接干掉所有的对象


ArrayList alcollect = new ArrayList();

alcollect.Clear();




 

posted on 2021-10-22 15:47  odsxe  阅读(128)  评论(0编辑  收藏  举报