IsReadOnly property of ArrayList

In this article I will explain the IsReadOnly property of ArrayList.
  • 1723

Introduction

The IsReadOnly property of ArrayList gets a value indicating whether the ArrayList is read-only, or not if yes then it return true otherwise it return false.

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");

            // Creates a read-only copy of the ArrayList.

            ArrayList ReadOnly = ArrayList.ReadOnly(days);

            // Displays whether the ArrayList is read-only or writable.

            Console.WriteLine("ArrayList days is ReadOnly or not: {0}.", days.IsReadOnly);

            Console.WriteLine("ArrayList ReadOnly is ReadOnly or not: {0}.", ReadOnly.IsReadOnly);

        }

    }

}

 

Output

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