Discussion board
How to use the foreach loop ?
By Arun Desai
foreach loop......
Reply
Post   Reset
Teacher SiliconIndia replied to Arun Desai Wednesday, March 17, 2010
Hi Arun,
The Foreach loop is a variation of the For loop and allows you to iterate over elements in an array. There are two different versions of the Foreach loop. The Foreach loop syntaxes are as follows:
foreach (array as value)
{
code to be executed;
}

foreach (array as key => value)
{
code to be executed;
}