C# foreach loop ➰

11 Views
Published
C# foreach loop tutorial example explained

#C# #foreach #loop

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// foreach loop = a simpler way to iterate over an array, but it's less flexible

String[] cars = {"BMW", "Mustang", "Corvette"};

foreach (String car in cars)
{
Console.WriteLine(car);
}

Console.ReadKey();
}
}
}
Category
Bro Code
Tags
c#, programming, tutorial
Be the first to comment