Get an object that can be used to synchronize access to the StringCollection in CSharp
Description
The following code shows how to get an object that can be used to synchronize access to the StringCollection.
Example
using System;/*from w w w . j a v a 2 s. co m*/
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringCollection {
public static void Main() {
StringCollection myCollection = new StringCollection();
lock(myCollection.SyncRoot)
{
foreach (object item in myCollection)
{
// Insert your code here.
Console.WriteLine("code");
}
}
}
}