संपादित करें

इसके माध्यम से साझा किया गया


ConcurrentDictionary<TKey,TValue> Constructors

Definition

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class.

Overloads

ConcurrentDictionary<TKey,TValue>()

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>)

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable<T>, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

ConcurrentDictionary<TKey,TValue>(IEqualityComparer<TKey>)

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level and capacity, and uses the specified IEqualityComparer<T>.

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable has the default concurrency level, has the default initial capacity, and uses the specified IEqualityComparer<T>.

ConcurrentDictionary<TKey,TValue>(Int32, Int32)

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the key type.

ConcurrentDictionary<TKey,TValue>(Int32, IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable, and uses the specified IEqualityComparer<T>.

ConcurrentDictionary<TKey,TValue>(Int32, Int32, IEqualityComparer<TKey>)

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<T>.

ConcurrentDictionary<TKey,TValue>()

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

public:
 ConcurrentDictionary();
public ConcurrentDictionary ();
Public Sub New ()

Remarks

The default concurrency level is equal to the number of CPUs. The higher the concurrency level is, the more concurrent write operations can take place without interference and blocking. Higher concurrency level values also cause operations that require all locks (for example, table resizing, ToArray and Count) to become more expensive. The default capacity (DEFAULT_CAPACITY), which represents the initial number of buckets, is a trade-off between the size of a very small dictionary and the number of resizes when constructing a large dictionary. Also, the capacity should not be divisible by a small prime number. The default capacity is 31.

See also

Applies to

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable<T>, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

public:
 ConcurrentDictionary(System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection);
public ConcurrentDictionary (System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)))

Parameters

collection
IEnumerable<KeyValuePair<TKey,TValue>>

The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

Exceptions

collection or any of its keys is null.

collection contains one or more duplicate keys.

See also

Applies to

ConcurrentDictionary<TKey,TValue>(IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level and capacity, and uses the specified IEqualityComparer<T>.

public:
 ConcurrentDictionary(System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (comparer As IEqualityComparer(Of TKey))

Parameters

comparer
IEqualityComparer<TKey>

The equality comparison implementation to use when comparing keys.

Exceptions

comparer is null.

See also

Applies to

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable has the default concurrency level, has the default initial capacity, and uses the specified IEqualityComparer<T>.

public:
 ConcurrentDictionary(System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), comparer As IEqualityComparer(Of TKey))

Parameters

collection
IEnumerable<KeyValuePair<TKey,TValue>>

The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

comparer
IEqualityComparer<TKey>

The IEqualityComparer<T> implementation to use when comparing keys.

Exceptions

collection or comparer is null.

See also

Applies to

ConcurrentDictionary<TKey,TValue>(Int32, Int32)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the key type.

public:
 ConcurrentDictionary(int concurrencyLevel, int capacity);
public ConcurrentDictionary (int concurrencyLevel, int capacity);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : int * int -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (concurrencyLevel As Integer, capacity As Integer)

Parameters

concurrencyLevel
Int32

The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently, or in .NET 8+ only, -1 to indicate the default concurrency level.

capacity
Int32

The initial number of elements that the ConcurrentDictionary<TKey,TValue> can contain.

Exceptions

concurrencyLevel is less than 1.

-or-

capacity is less than 0.

See also

Applies to

ConcurrentDictionary<TKey,TValue>(Int32, IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable, and uses the specified IEqualityComparer<T>.

public:
 ConcurrentDictionary(int concurrencyLevel, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (int concurrencyLevel, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (int concurrencyLevel, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : int * seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (concurrencyLevel As Integer, collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), comparer As IEqualityComparer(Of TKey))

Parameters

concurrencyLevel
Int32

The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently, or in .NET 8+ only, -1 to indicate the default concurrency level.

collection
IEnumerable<KeyValuePair<TKey,TValue>>

The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

comparer
IEqualityComparer<TKey>

The IEqualityComparer<T> implementation to use when comparing keys.

Exceptions

collection or comparer is null.

concurrencyLevel is less than 1.

collection contains one or more duplicate keys.

See also

Applies to

ConcurrentDictionary<TKey,TValue>(Int32, Int32, IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<T>.

public:
 ConcurrentDictionary(int concurrencyLevel, int capacity, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (int concurrencyLevel, int capacity, System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (int concurrencyLevel, int capacity, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : int * int * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (concurrencyLevel As Integer, capacity As Integer, comparer As IEqualityComparer(Of TKey))

Parameters

concurrencyLevel
Int32

The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently, or in .NET 8+ only, -1 to indicate the default concurrency level.

capacity
Int32

The initial number of elements that the ConcurrentDictionary<TKey,TValue> can contain.

comparer
IEqualityComparer<TKey>

The IEqualityComparer<T> implementation to use when comparing keys.

Exceptions

comparer is null.

concurrencyLevel or capacity is less than 1.

See also

Applies to