How to print ArrayList using foreach loop in C#

1 Answer

0 votes
using System;
using System.Collections;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList alist = new ArrayList();

            alist.Add("java");
            alist.Add("c#");
            alist.Add("c++");
            alist.Add("c");
            alist.Add("python");

            foreach (string s in alist)
                Console.WriteLine(s);
        }
    }
}

/*
run:

java
c#
c++
c
python

*/

 



answered Jan 7, 2017 by avibootz

Related questions

2 answers 249 views
2 answers 256 views
1 answer 188 views
1 answer 191 views
2 answers 283 views
1 answer 184 views
...