C#从ArrayList中删除对象的代码

2021-11-05  本文已影响0人  简简单单咦

在学习期间,将写内容过程中比较重要的内容记录起来,下面内容是关于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();

上一篇下一篇

猜你喜欢

热点阅读