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 185 views
1 answer 222 views
222 views asked Feb 20, 2017 by avibootz
1 answer 166 views
1 answer 119 views
1 answer 190 views
1 answer 189 views
189 views asked Apr 30, 2017 by avibootz
1 answer 112 views
...