Method TryAdd
TryAdd(TKey, TValue)
Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public bool TryAdd(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The object to use as the key of the element to add. |
TValue | value | The object to use as the value of the element to add. |
Returns
Type | Description |
---|---|
System.Boolean |
TryAdd(TKey, Func<TKey, TValue>)
Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey, TValue> by calling the provided factory method to construct the value if the key is not already present in the collection.
Declaration
public bool TryAdd(TKey key, Func<TKey, TValue> fnCreate)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | |
Func<TKey, TValue> | fnCreate |
Returns
Type | Description |
---|---|
System.Boolean |