find item in arraylist using indexof method

IndexOf method is used to determine if a particular item exists in an ArrayList. If an item exists, the index of that item is returned and if the item does not exist, -1 is returned.



private void Form1_Load(object sender, EventArgs e)
{
	ArrayList arrayList = new ArrayList();
	arrayList.Add("Customer1");
	arrayList.Add("Customer2");
	arrayList.Add("Customer3");
	arrayList.Add("Customer4");
	arrayList.Add("Customer5");
	MessageBox.Show(arrayList.IndexOf("Customer1").ToString());
}

The above statement returns zero because "Customer1" is the first item in the ArrayList.