For Loop
using System;
public class Iteration
{
static void Main(String[] args)
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Value : " + i); /* It will display the value of i
until the condition i<5 is true */
}
Console.WriteLine("
Enhanced for loop");
String[] myString = new String[] { "one", "two", "three", "four" };
Console.WriteLine("--------------------");
foreach (String str in myString)
{
/*iterating each string in the string array mystring*/
Console.WriteLine(str);
}
Console.ReadLine();
}
}
Output:
Value = 0
Value = 1
Value = 2
Value = 3
Value = 4
Enhanced for loop
--------------------
one
two
three
four