Summary
Gets the element with the specified key or adds it if it is not in the dictionary.
Syntax
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dicionary, TKey key, Func<TKey, TValue> getValue)
Type Parameters
Name |
Description |
TKey |
The type of keys in the dictionary. |
TValue |
The type of values in the dictionary. |
Parameters
Name |
Type |
Description |
dicionary |
IDictionary<TKey, TValue> |
The dictionary to get element from. |
key |
TKey |
The key of the element to get. |
getValue |
Func<TKey, TValue> |
The callback delegate to return value if element with specified key does not exist in the dicionary. |
Return Value
Type |
Description |
TValue |
The element with the specified key, or the added value. |