Get an object that can be used to synchronize access to the Hashtable in CSharp

Description

The following code shows how to get an object that can be used to synchronize access to the Hashtable.

Example


using System.Collections;
using System;/*w w w  .j  a va2s. c  o  m*/
public class MainClass{
  public static void Main(String[] argv){  
    Hashtable myCollection = new Hashtable();
    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