Foreach Loop in C#:-
It is the special loop in C# that is used to display the array elements specially, It is the modified form of for loop.
Syntax of foreach
It is the special loop in C# that is used to display the array elements specially, It is the modified form of for loop.
Syntax of foreach
foreach(var in arrayvar1)
{
Statements;
}
Example of Foreach Loop Based Program in C#:-
class ObjectArr
{
static void Main()
{
// object [] arr = {"C","CPP",1200,12.34F,true,'a' };
int[] arr = { 12, 23, 11, 45, 67 };
foreach (int a in arr)
{
Console.WriteLine(a);
}
}
Post a Comment
If you have any doubt in programming or join online classes then you can contact us by comment .