Home  >  Article  >  Backend Development  >  CopyOnWriteArrayList version in C#

CopyOnWriteArrayList version in C#

王林
王林forward
2023-09-08 13:25:021303browse

C# 中的 CopyOnWriteArrayList 版本

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete