Return a read-only ArrayList wrapper in CSharp

Description

The following code shows how to return a read-only ArrayList wrapper.

Example


using System;/*  w w  w  . j av a2  s . c  o 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 »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary