Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
class Program
{
static void Main(string[] args)
{
int i = 0;
ArrayList IList = new ArrayList();
IList.Add("Item4");
IList.Add("Item5");
IList.Add("Item2");
IList.Add("Item1");
IList.Add("Item3");
Console.WriteLine("Shows Added Items");
for (i = 0; i <=IList.Count - 1; i++)
{
Console.WriteLine(IList[i]);
}
Console.WriteLine(" List before sorting");
//insert an item
IList.RemoveAt(3);
IList.Insert(3, "Item6");
IList.RemoveRange(1,3);
Console.WriteLine(" List after sorting");
for (i = 0; i <= IList.Count - 1; i++)
{
Console.WriteLine(IList[i]);
}
The above program shows the program for Array list and the methods and properties being used into it , so you can just take a look on he methods that are RemoveAt and insert methods are listed over there that can be used to remove and insert items in the Array list.
Bookmarks