Use for foreach loop to print value in an array in CSharp
Description
The following code shows how to use for foreach loop to print value in an array.
Example
//w w w . j av a 2s . c o m
using System;
public class MainClass {
static void Main(string[] args)
{
int[] intArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
foreach (int i in intArray)
{
Console.WriteLine(i);
}
}
}
The code above generates the following result.