C# Array IsSynchronized
Description
Array IsSynchronized
gets a value indicating whether
access to the Array is synchronized (thread safe).
Syntax
Array.IsSynchronized
has the following syntax.
public bool IsSynchronized { get; }
Example
The following code example shows how to lock an array during the entire enumeration by using the SyncRoot property.
using System;/*from ww w.j a v a2s . c o m*/
public class MainClass{
public static void Main(String[] argv){
Array myArray = new int[] { 1, 2, 4 };
lock(myArray.SyncRoot)
{
foreach (Object item in myArray)
Console.WriteLine(item);
}
}
}
The code above generates the following result.