IsFixedSize Property of ArrayList

In this article I will explain the IsFixedSize Property of ArrayList.
  • 2317

Introduction

IsFixedSize Property of ArrayList gets a value indicating whether the ArrayList has a fixed size or not if yes then it return true and if not then return false. In my example I use the conditional statement to display whether the arraylist has fixed size or not.

Example

namespace ConsoleApplication2

{

    class Program

    {

        static void Main(string[] args)

        {

            //create the arraylist

            ArrayList arraylist1 = new ArrayList(5);

            arraylist1.Add("June");

            arraylist1.Add("July");

            arraylist1.Add("August");

            arraylist1.Add("September");

            arraylist1.Add("October");

            Console.WriteLine("THE ELEMENTS OF THE ARRAYLIST ARE:");

            Console.WriteLine();

            foreach (string i in arraylist1)

            {

                Console.WriteLine(i);

            }

            // Create a fixed-size wrapper around the ArrayList.

            ArrayList FixedSize = ArrayList.FixedSize(arraylist1);

            // Display whether the ArrayLists have a fixed size or not.

            Console.WriteLine();

            Console.WriteLine("arraylist1 {0}.", arraylist1.IsFixedSize ? "has a fixed size" : "does not have a fixed size");

            Console.WriteLine("FixedSize {0}.", FixedSize.IsFixedSize ? "has a fixed size" : "does not have a fixed size");

            Console.WriteLine();

        }

    }

}

 

Output

 

isfixedsize.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.