The Wayback Machine - https://web.archive.org/web/20240306101108/https://www.geeksforgeeks.org/c-sharp-check-if-stringcollection-is-synchronized-thread-safe/
Open In App
Related Articles

C# | Check if StringCollection is synchronized (thread safe)

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report
StringCollection class is a new addition to the .NET Framework class library that represents a collection of strings. StringCollection class is defined in the System.Collections.Specialized namespace. StringCollection.IsSynchronized property is used to get a value indicating whether access to the StringCollection is synchronized (thread safe) or not. Syntax:
public bool IsSynchronized { get; }
Return Value: This property always returns false. Note: Retrieving the value of this property is an O(1) operation. Example:
// C# code to check if StringCollection
// is synchronized (thread safe)
using System;
using System.Collections;
using System.Collections.Specialized;
  
class GFG {
  
    // Driver code
    public static void Main()
    {
  
        // creating a StringCollection named myCol
        StringCollection myCol = new StringCollection();
  
        // creating a string array named myArr
        String[] myArr = new String[] { "A", "B", "C", "D", "E" };
  
        // Copying the elements of a string
        // array to the end of the StringCollection.
        myCol.AddRange(myArr);
  
        // checking if StringCollection is
        // synchronized (thread safe)
        Console.WriteLine(myCol.IsSynchronized);
    }
}

                    
Output:
False
Reference:

Last Updated : 01 Feb, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads