1d.. (iv). Use of foreach loop with arrays

Program:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prac1_d4
{
using A = System.Console;

class Program
{
static void Main(string[] args)

{
int[] arr1 = new int[5] { 1, 2, 3, 4, 5 };

string[] arr2 = new string[5] {"ABC","DEF","GHI","JKL","MNO"}; A.WriteLine("Elements in array 1st: ");

foreach (int i in arr1)

{
A.WriteLine(i);

}
A.WriteLine("Elements in array 2nd: ");
foreach (string i in arr2)

{
A.WriteLine(i);

}
A.ReadKey();

}
}

}

Comments