foreach loop in C#

Program:- Example of foreach loop in c#

Source Code:-

class ForEachExa
{
    static void Main(string[] args)
    {
        int[] array = new int[] { 0, 3, 7, 5, 8, 8, 12 };
        foreach (int i in array)
        {
            System.Console.WriteLine(i);
        }
    }
}


Output:-
0
3
7
5
8
8
12

Popular Posts