Remove a range of elements from the ArrayList in CSharp
Description
The following code shows how to remove a range of elements from the ArrayList.
Example
using System;//from www. j a va 2s .c o m
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
ArrayList myList = new ArrayList();
myList.Add("java2s.com");
myList.Add("A");
myList.Add("B");
myList.Add("C");
myList.Add("D");
myList.Add("E");
myList.Add("F");
myList.Add("G");
myList.Add("H");
myList.Add("I");
myList.Add("J");
foreach (string item in myList) {
Console.WriteLine(item);
}
myList.RemoveRange(2, 2);
foreach (string item in myList) {
Console.WriteLine(item);
}
}
}
The code above generates the following result.