Lock a ArrayList in CSharp
Description
The following code shows how to lock a ArrayList.
Example
using System;//from w w w.ja v a 2 s . c o m
using System.Collections;
public class MainClass{
public static void Main(String[] argv){
ArrayList myCollection = new ArrayList();
lock(myCollection.SyncRoot)
{
foreach (object item in myCollection)
{
// Insert your code here.
Console.WriteLine("changing");
}
}
}
}