Get an object to synchronize access to a SortedList in CSharp

Description

The following code shows how to get an object to synchronize access to a SortedList.

Example


/*from ww  w  .  j av  a2s .co  m*/
using System.Collections;
using System;
public class MainClass{
  public static void Main(String[] argv){  
    SortedList myCollection = new SortedList();
    lock(myCollection.SyncRoot)
    {
        foreach (object item in myCollection)
        {
            // Insert your code here.
            Console.WriteLine("code");
        }
    }
  }
}




















Home »
  C# Tutorial »
    Collections »




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