SynchronizedKeyedCollection<K,T> Constructors

Definition

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class.

Overloads

SynchronizedKeyedCollection<K,T>()

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class.

SynchronizedKeyedCollection<K,T>(Object)

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class with access synchronized by an explicitly specified object.

SynchronizedKeyedCollection<K,T>(Object, IEqualityComparer<K>)

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class with access synchronized by an explicitly specified object and with keys compared in a specified way.

SynchronizedKeyedCollection<K,T>(Object, IEqualityComparer<K>, Int32)

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class with access synchronized by an explicitly specified object and with keys compared in a specified way.

SynchronizedKeyedCollection<K,T>()

Source:
SynchronizedKeyedCollection.cs
Source:
SynchronizedKeyedCollection.cs

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class.

C#
protected SynchronizedKeyedCollection();

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

SynchronizedKeyedCollection<K,T>(Object)

Source:
SynchronizedKeyedCollection.cs
Source:
SynchronizedKeyedCollection.cs

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class with access synchronized by an explicitly specified object.

C#
protected SynchronizedKeyedCollection(object syncRoot);

Parameters

syncRoot
Object

The object used to synchronize access to the thread-safe collection.

Exceptions

syncRoot is null.

Remarks

If multiple instances of the SynchronizedKeyedCollection<K,T> are created using the same syncRoot, then access is protected across all instances.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

SynchronizedKeyedCollection<K,T>(Object, IEqualityComparer<K>)

Source:
SynchronizedKeyedCollection.cs
Source:
SynchronizedKeyedCollection.cs

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class with access synchronized by an explicitly specified object and with keys compared in a specified way.

C#
protected SynchronizedKeyedCollection(object syncRoot, System.Collections.Generic.IEqualityComparer<K> comparer);

Parameters

syncRoot
Object

The object used to synchronize access to the thread-safe collection.

comparer
IEqualityComparer<K>

The IEqualityComparer<T> of type K used to compare key objects of type K for equality.

Exceptions

syncRoot is null or comparer is null.

Remarks

The generic parameter K used by the IEqualityComparer<T> input parameter is the first generic parameter for this class. This allows us to compare keys for equality in a customized way that can be used, for example, to optimize on the most critical aspects of the comparison.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

SynchronizedKeyedCollection<K,T>(Object, IEqualityComparer<K>, Int32)

Source:
SynchronizedKeyedCollection.cs
Source:
SynchronizedKeyedCollection.cs

Initializes a new instance of the SynchronizedKeyedCollection<K,T> class with access synchronized by an explicitly specified object and with keys compared in a specified way.

C#
protected SynchronizedKeyedCollection(object syncRoot, System.Collections.Generic.IEqualityComparer<K> comparer, int dictionaryCreationThreshold);

Parameters

syncRoot
Object

The object used to synchronize access to the thread-safe collection.

comparer
IEqualityComparer<K>

The IEqualityComparer<T> of type K used to compare key objects of type K for equality.

dictionaryCreationThreshold
Int32

The number of items required to create a dictionary for the collection.

Exceptions

syncRoot is null or comparer is null.

dictionaryCreationThreshold is less than -1.

Remarks

Setting dictionaryCreationThreshold to -1 assigns the MaxValue (2,147,483,647; hexadecimal 0x7FFFFFFF) to it.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1