FOREACH LOOP IN C#

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C# 
C#
 506  View(s)
Ratings:
Rate this:
I want to use foreach loop in c# please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: foreach loop In c#

    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();

    }

    }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!