Array with For Loop
using System;
// Displaying an array using for loop.
public class ArrayForLoop
{
static void Main(String[] args)
{
String[] myArray;
myArray = new String[10];
myArray[0] = "aa";
myArray[1] = "bb";
myArray[2] = "cc";
int size = myArray.Length; // We need to get the size of the array using Length property.
Console.WriteLine("Elements of the array: ");
for (int i = 0; i < size; i++)
{
Console.WriteLine(myArray[i]);
}
Console.ReadLine();
}
}
Output:
Elements of the array:
aa
bb
cc