C# BitArray SyncRoot

Description

BitArray SyncRoot gets an object that can be used to synchronize access to the BitArray.

Syntax

BitArray.SyncRoot has the following syntax.


public Object SyncRoot { get; }

Example

The following code example shows how to lock the collection using the SyncRoot during the entire enumeration.


using System;/*  www.  j  a  va 2s. com*/
using System.Collections;
public class SamplesBitArray  {
   public static void Main()  {
    BitArray myCollection = new BitArray(64, true);
    lock(myCollection.SyncRoot)
    {
        foreach (object item in myCollection)
        {
            // Insert your code here.
        }
    }
   }
}




















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack