CopyOnWriteArrayList version in C#

CsharpProgrammingServer Side Programming

Java has CopyOnWriteArrayList, but C# does not have it. For that, the SynchronizedCollection Class in C#, should be preferred.

The SyncronizedCollection has a thread-safe collection containing objects of a type. Here 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# −

Sr.No.Property Name & Description
1Count
Counts the number of elements in the thread-safe collection.
2Item[Int32]
Gets an element from the thread-safe collection with a specified index.
3Items
Gets the list of elements contained in the thread-safe collection.
4SyncRoot
Gets the object used to synchronize access to the thread-safe collection.
raja
Published on 21-Aug-2018 07:53:45
Advertisements