C# | Check if StringCollection is synchronized (thread safe)
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); } } |
False
Reference:
Recommended Posts:
- C# | Check if ArrayList is Synchronized (thread safe)
- C# | Check if the BitArray is synchronized (thread safe)
- C# | Check if ListDictionary is synchronized (thread safe)
- C# | Check if Hashtable is synchronized (thread safe)
- C# | Check if an array is synchronized (thread safe) or not
- C# | Check if StringDictionary is synchronized (thread safe)
- C# | Check if HybridDictionary is Synchronized (thread safe)
- C# | Creating a synchronized (thread-safe) wrapper for the Hashtable
- C# | Creating a synchronized (thread-safe) wrapper for the ArrayList
- C# | Creating a synchronized (thread-safe) wrapper for a SortedList object
- C# | Check if a thread belongs to managed thread pool or not
- How to check whether a thread is a background thread or not in C#
- C# | Check if a SortedList object is synchronized
- C# | Check if the StringCollection is read-only
- C# | Check if the specified string is in the StringCollection
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



