C# ArrayList ReadOnly(ArrayList)

Description

ArrayList ReadOnly(ArrayList) returns a read-only ArrayList wrapper.

Syntax

ArrayList.ReadOnly(ArrayList) has the following syntax.


public static ArrayList ReadOnly(
  ArrayList list
)

Parameters

ArrayList.ReadOnly(ArrayList) has the following parameters.

  • list - The ArrayList to wrap.

Returns

ArrayList.ReadOnly(ArrayList) method returns A read-only ArrayList wrapper around list.

Example

The following code example shows how to create a read-only wrapper around an ArrayList and how to determine if an ArrayList is read-only.


using System;/*from  w  ww  .  j a  va2s .  co  m*/
using System.Collections;
 public class SamplesArrayList  {

    public static void Main()  {
       ArrayList myAL = new ArrayList();
       myAL.Add( "A" );
       myAL.Add( "B" );
       myAL.Add( "C" );

       ArrayList myReadOnlyAL = ArrayList.ReadOnly( myAL );

       Console.WriteLine(myAL.IsReadOnly);
       Console.WriteLine(myReadOnlyAL.IsReadOnly);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack