Array with Enhanced For Loop
using System;
// Displaying an array using foreach loop.
public class ArrayForEachLoop
{
static void Main(String[] args)
{
String[] myArray;
myArray = new String[10];
myArray[0] = "aa";
myArray[1] = "bb";
myArray[2] = "cc";
// We do not need to get the size of array.
Console.WriteLine("Elements of the array: ");
foreach (string val in myArray) // Each element in myArray is a string
{
Console.WriteLine(val);
}
Console.ReadLine();
}
}
Output:
Elements of the array:
aa
bb
cc