C# | Check if the ArrayList is readonly (original) (raw)

Last Updated : 01 Feb, 2019

ArrayList represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. It also allows dynamic memory allocation, adding, searching and sorting items in the list. ArrayList.IsReadOnly property is used to check whether the ArrayList is read-only or not.Properties:

Syntax:

public virtual bool IsReadOnly { get; }

Return Value: This method returns True if the ArrayList is read-only, otherwise returns False. The default value is False.Example:

CSHARP `

// C# code to check if the ArrayList // is read-only or not using System; using System.Collections; using System.Collections.Generic;

class GFG {

// Driver code
public static void Main()
{

    // Creating an ArrayList
    ArrayList myList = new ArrayList();

    // Adding elements to ArrayList
    myList.Add("Geeks");
    myList.Add("for");
    myList.Add("Geeks");
    myList.Add("Noida");
    myList.Add("Geeks Classes");
    myList.Add("Delhi");

    // To check if the ArrayList is read-only or not
    Console.WriteLine(myList.IsReadOnly);
}

}

`

Note:

Reference:

Similar Reads