How to create, add elements and print an ArrayList in C#

2 Answers

0 votes
using System;
using System.Collections;

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

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

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

/*
run:

c#
java
c++
c

*/

 



answered Jan 6, 2017 by avibootz
0 votes
using System;
using System.Collections;

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

            alist.Add(190);
            alist.Add(42);
            alist.Add(13);
            alist.Add(18181);

            foreach (int n in alist)
                Console.WriteLine(n);
        }
    }
}

/*
run:

190
42
13
18181

*/

 



answered Jan 6, 2017 by avibootz

Related questions

1 answer 110 views
1 answer 176 views
1 answer 212 views
212 views asked Feb 20, 2017 by avibootz
1 answer 158 views
1 answer 182 views
1 answer 178 views
178 views asked Apr 30, 2017 by avibootz
1 answer 104 views
...