foreach loop is a different kind of looping constructs in C# programming that doesn’t includes initialization, termination and increment/decrement characteristics. It uses collection to take value one by one and then processes them.
using System;
using System.Collections;
namespace ForEachLoop
{
class Program
{ static void Main(string[] args)
{
ArrayList list = new ArrayList();
list.Add("Suresh Kumar");
list.Add("Sanjay Kumar");
list.Add("Sunil Patel");
list.Add("Vinay Singh");
list.Add("Arun varma");
list.Add("Manoj Kumar");
foreach (string name in list)
Console.WriteLine(name);
Console.ReadLine();
}
}
}
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
foreach loop is a different kind of looping constructs in C# programming that doesn’t includes initialization, termination and increment/decrement characteristics. It uses collection to take value one by one and then processes them.