retrieve arraylist items using for each loop


Using For..Each loop, we can iterate the items of the ArrayList collection. For..Each loop uses enumerators to iterate through all the items in the collection. Using ForEach loop, we can specify the data type which saves time for the loop to execute and also hides the complexity of the enumerators.
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");
	//Iterating through items - Using foreach loop
	string str = string.Empty;
	foreach (string strName in arrayList)
	{
		str += strName + "\n";
	}
	MessageBox.Show(str);