Program that uses ArrayList parameter :

class Program
{
public static void Main()
{
ArrayList list = new ArrayList();
list.Add(2);
list.Add(3);               // Add two integers in ArrayList

Example(list);           // Here Example is a method
}

static void Example(ArrayList list)
{
foreach(int abc in list)
{
Console.Writeline(abc);
Console.ReadLine();
}
}
}
OUTPUT :
2
3
—————*—————-

Insert and remove of an element from an array :

How to remove an element from an array : 


class Program
{
static void Main()
{
ArrayList list = new ArrayList()
list.Add(“Imrez”);
list.Add(“Khan”);
list.Add(“Ratin”);

list.RemoveAt(1);        // It removes the element of  1st position which is “Khan”.

foreach (string i in list)
{
Console.WriteLine(i);
Console.ReadLine();
}
}
}
Output :
Imrez
Ratin
———————–*———————

How to insert an element in an array :

class Program
{
static void Main()
{
ArrayList list = new ArrayList()
list.Add(“Imrez”);
list.Add(“Khan”);
list.Add(“Ratin”);

list.Insert(0,”Mr.”);   //It insert an element in zero number position which is “Mr.”

foreach (string i in list)
{
Console.WriteLine(i);
Console.ReadLine();
}
}
}
Output :
Mr.
Imrez
Khan
Ratin
———————–*———————

How to use Count and Clear() :

class Program
{
static void Main()
{
ArrayList list = new ArrayList();
list.Add(3);
list.Add(8);

list.Add(10);
list.Add(52);

Console.WriteLine(list.Count);  // Show number of element in ArrayList and output=4
list.Clear();                               // Clear all the elements of ArrayList.

Console.WriteLine(list.Count);   // Again count the number of element.
Console.ReadLine();                  // Output = 0
}
}

———————–*———————–