Get a read-only copy of the OrderedDictionary in CSharp

Description

The following code shows how to get a read-only copy of the OrderedDictionary.

Example


using System;/*  w  ww .  j  a va 2s . c  om*/
using System.Collections;
using System.Collections.Specialized;

public class SamplesStringCollection  {

   public static void Main()  {
        OrderedDictionary myOrderedDictionary = new OrderedDictionary();
        myOrderedDictionary.Add("testKey1", "testValue1");
        myOrderedDictionary.Add("testKey2", "testValue2");
        myOrderedDictionary.Add("testKey3", "testValue3");

        OrderedDictionary my = myOrderedDictionary.AsReadOnly();
        
        Console.WriteLine(my.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