a foreach loop

image_pdfimage_print

   

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/

/*
  Example4_12.cs illustrates the use of
  a foreach loop
*/

public class Example4_12
{

  public static void Main()
  {

    int [] myValues = {2, 4, 3, 5, 1};
    foreach (int counter in myValues)
    {
      System.Console.WriteLine("counter = " + counter);
    }

  }

}