下面的代码详细演示了ArrayList如果通过各种方法删除集合内的单个或者多个对象
通过Remove方法直接删除指定的对象
ArrayList alcollect = new ArrayList(); // Add individual items to the collection string str = "learn csharp"; alcollect.Add(str); alcollecti.Remove(str);
通过RemoveAt方法根据索引号删除对象
ArrayList alcollect = new ArrayList(); // Removes first item in ArrayList alcollect.RemoveAt(0);
RemoveRange方法根据索引范围删除对象
ArrayList alcollect = new ArrayList(); // Removes first four items in ArrayList alcollect.RemoveRange(0, 4);
Clear方法直接干掉所有的对象
ArrayList alcollect = new ArrayList(); // Removes all objects in ArrayList alcollect.Clear();