Namespace: System.Collections.Concurrent
ConcurrentDictionary<TKey, TValue>
Represents a thread-safe collection of key/value pairs that can be accessed by multiple threads concurrently.
Properties (1)
TValue Item(T)
Gets or sets the value associated with the specified key.
Value: The value of the key/value pair at the specified index.
Methods (3)
bool TryGetValue(T,TValue@)
Attempts to get the value associated with the specified key from the ConcurrentDictionary.
| Parameter | Description |
|---|---|
| key | The key of the value to get. |
| value | When this method returns, contains the object from the ConcurrentDictionary that has the specified key, or the default value of the type if the operation failed. |
Returns: true if the key was found in the ConcurrentDictionary; otherwise, false.
bool TryAdd(T,TValue)
Attempts to add the specified key and value to the ConcurrentDictionary.
| Parameter | Description |
|---|---|
| key | The key of the element to add. |
| value | The value of the element to add. The value can be null for reference types. |
Returns: true if the key/value pair was added to the ConcurrentDictionary successfully; false if the key already exists.
bool ContainsKey(T)
Determines whether the ConcurrentDictionary contains the specified key.
| Parameter | Description |
|---|---|
| key | The key to locate in the ConcurrentDictionary. |
Returns: true if the ConcurrentDictionary contains an element with the specified key; otherwise, false.