Home >Backend Development >C#.Net Tutorial >CopyOnWriteArrayList version in C#
Java has CopyOnWriteArrayList, but C# does not. For this purpose, the SynchronizedCollection class in C# should be used in preference.
SynchronizedCollection is a thread-safe collection containing objects of a specific type. The following is the syntax.
public class SynchronizedCollection<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection
Above, T is the type of object.
The following are the properties of the SyncronizedCollection class in C#-
Advanced number | Property name and description |
---|---|
1 |
Count Counts the number of elements in a thread-safe collection. |
2 |
Item[Int32] Gets an element specified from a thread-safe collection index. |
3 |
Items Get the number of elements contained in the list thread-safe collection. |
4 |
SyncRoot Gets the object used for synchronous access to thread-safe collections. |
The above is the detailed content of CopyOnWriteArrayList version in C#. For more information, please follow other related articles on the PHP Chinese website!