For Each Statement In C Sharp

The foreach statement is used to iterate through the collection or an array.
If we think that foreach statement is created for replace the for statement.
We cannot use initialization,condition,increment\decrement in the for statement.


--------------------------------------------------------------------------------------------------------------
using System;


class ForEachTest
{
public static void Main()
{
int[] i_arr = {44,42,3,4,57,67,56};
foreach(int i in i_arr)
{
Console.WriteLine("Value of i is " + i);
}
}
}



----------------------------------------------------------------------------------------------------------





For Each Statement In C Sharp For Each Statement In C Sharp Reviewed by Baljeet Singh on 02:09 Rating: 5

No comments:

Powered by Blogger.