TryAdd Method
Definition
- Namespace
- Cuemon.Extensions.Collections.Generic
- Assemblies
- Cuemon.Extensions.Collections.Generic.dll
TryAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue, Func<IDictionary<TKey, TValue>, bool>)
Attempts to add the specified key and value to the dictionary.
public static bool TryAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value, Func<IDictionary<TKey, TValue>, bool> condition)
Parameters
dictionaryIDictionary<TKey, TValue>The IDictionary<TKey, TValue> to extend.
keyTKeyThe key of the element to add.
valueTValueThe value of the element to add.
conditionFunc<IDictionary<TKey, TValue>, bool>The function delegate that specifies the condition for adding the element.
Returns
- bool
trueif the key/value pair was added to thedictionarysuccessfully; otherwise,false.
Type Parameters
TKeyTValue
Exceptions
- ArgumentNullException
dictionarycannot be null -or-keycannot be null -or-conditioncannot be null.