Check if the BitArray is synchronized (thread safe) in CSharp
Description
The following code shows how to check if the BitArray is synchronized (thread safe).
Example
//from w w w .ja v a 2 s . co m
using System;
using System.Linq;
using System.Collections;
public class MainClass{
public static void Main(String[] argv){
BitArray myCollection = new BitArray(64, true);
lock(myCollection.SyncRoot)
{
foreach (object item in myCollection)
{
// Insert your code here.
Console.WriteLine("code");
}
}
}
}
The code above generates the following result.