Mega Code Archive

 
Categories / C# / Collections Data Structure
 

SortedList IsSynchronized tells whether access to a SortedList object is synchronized (thread safe)

using System; using System.Collections; public class SamplesSortedList  {    public static void Main()  {       SortedList mySL = new SortedList();       mySL.Add( 2, "two" );       mySL.Add( 3, "three" );       mySL.Add( 1, "one" );       mySL.Add( 0, "zero" );       mySL.Add( 4, "four" );       SortedList mySyncdSL = SortedList.Synchronized( mySL );       Console.WriteLine( "mySL is {0}.", mySL.IsSynchronized ? "synchronized" : "not synchronized" );       Console.WriteLine( "mySyncdSL is {0}.", mySyncdSL.IsSynchronized ? "synchronized" : "not synchronized" );    } }