How to print ArrayList using for 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");

            for (int i = 0; i < alist.Count; i++)
            {
                string s = alist[i] as string;
                Console.WriteLine(s);
            }
        }
    }
}

/*
run:

java
c#
c++
c
python

*/

 



answered Jan 7, 2017 by avibootz

Related questions

1 answer 225 views
1 answer 196 views
1 answer 168 views
1 answer 111 views
111 views asked Jan 14, 2024 by avibootz
1 answer 155 views
1 answer 148 views
1 answer 205 views
...