<PackageReference Include="Namotion.Reflection" Version="2.0.4" />

ConcurrentDictionary<TKey, TValue>

class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IDictionary, ICollection
Represents a thread-safe collection of keys and values.
public int Count { get; }

Gets the number of key/value pairs contained in the ConcurrentDictionary<T, U>.

public bool IsEmpty { get; }

Gets a value that indicates whether the ConcurrentDictionary<T, U> is empty.

public TValue this[TKey key] { get; set; }

Gets or sets the value associated with the specified key.

public ICollection<TKey> Keys { get; }

Gets a collection containing the keys in the Dictionary{TKey,TValue}.

public ICollection<TValue> Values { get; }

Gets a collection containing the values in the Dictionary{TKey,TValue}.

Initializes a new instance of the ConcurrentDictionary<T, U> 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(int concurrencyLevel, int capacity)

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

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

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

public ConcurrentDictionary(IEqualityComparer<TKey> comparer)

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

public ConcurrentDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection, IEqualityComparer<TKey> comparer)

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

public ConcurrentDictionary(int concurrencyLevel, IEnumerable<KeyValuePair<TKey, TValue>> collection, IEqualityComparer<TKey> comparer)

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

public ConcurrentDictionary(int concurrencyLevel, int capacity, IEqualityComparer<TKey> comparer)

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

public TValue AddOrUpdate(TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)

Adds a key/value pair to the ConcurrentDictionary<T, U> if the key does not already exist, or updates a key/value pair in the ConcurrentDictionary<T, U> if the key already exists.

public TValue AddOrUpdate(TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)

Adds a key/value pair to the ConcurrentDictionary<T, U> if the key does not already exist, or updates a key/value pair in the ConcurrentDictionary<T, U> if the key already exists.

public void Clear()

Removes all keys and values from the ConcurrentDictionary<T, U>.

public bool ContainsKey(TKey key)

Determines whether the ConcurrentDictionary<T, U> contains the specified key.

public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()

Returns an enumerator that iterates through the ConcurrentDictionary<T, U>.

public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)

Adds a key/value pair to the ConcurrentDictionary<T, U> if the key does not already exist.

public TValue GetOrAdd(TKey key, TValue value)

Adds a key/value pair to the ConcurrentDictionary<T, U> if the key does not already exist.

public KeyValuePair<TKey, TValue>[] ToArray()

Copies the key and value pairs stored in the ConcurrentDictionary<T, U> to a new array.

public bool TryAdd(TKey key, TValue value)

Attempts to add the specified key and value to the ConcurrentDictionary<T, U>.

public bool TryGetValue(TKey key, out TValue value)

Attempts to get the value associated with the specified key from the ConcurrentDictionary<T, U>.

public bool TryRemove(TKey key, out TValue value)

Attempts to remove and return the the value with the specified key from the ConcurrentDictionary<T, U>.

public bool TryUpdate(TKey key, TValue newValue, TValue comparisonValue)

Compares the existing value for the specified key with a specified value, and if they're equal, updates the key with a third value.