ICollection Constructor in ArrayList

In this article I will explain the ArrayList Constructor (ICollection).
  • 3005

Introduction

The ArrayList Constructor (ICollection) initializes a new instance of the ArrayList class that contains elements copied from the specified collection and that has the same initial capacity as the number of elements copied.

Example

namespace ConsoleApplication6

{

    class Program

    {

        static void Main(string[] args)

        {

            // Creates a new ArrayList.

            ArrayList days = new ArrayList();

            days.Add("Sunday");

            days.Add("Monday");

            days.Add("Tuesday");

            days.Add("Wednesday");

            ArrayList days1 = new ArrayList(days);

            foreach (string s in days1)

            {

                Console.WriteLine(s);

            }

        }

    }

}

 

Output

constructor.jpg 

 

Ask Your Question  

Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.