Method GetOrAdd
GetOrAdd(TKey, TValue)
Adds a key/value pair to the System.Collections.Generic.IDictionary<TKey, TValue> if the key does not already exist.
Declaration
public TValue GetOrAdd(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the element to add. |
TValue | value | The value to be added, if the key does not already exist. |
Returns
Type | Description |
---|---|
TValue |
GetOrAdd(TKey, Func<TKey, TValue>)
Adds a key/value pair to the System.Collections.Generic.IDictionary<TKey, TValue> if the key does not already exist.
Declaration
public TValue GetOrAdd(TKey key, Func<TKey, TValue> fnCreate)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the element to add. |
Func<TKey, TValue> | fnCreate | Constructs a new value for the key. |
Returns
Type | Description |
---|---|
TValue |