Gets a value from the dictionary, adding and returning a new instance if it is missing.
public static TValue GetOrAddValue<TKey, TValue>(this IDictionary<TKey, TValue> dictionary,
TKey key)
where TValue : new()
parameter | description |
---|---|
dictionary | The dictionary. |
key | The key. |
The new or existing value.
Gets a value from the dictionary, adding and returning a new instance if it is missing.
public static TValue GetOrAddValue<TKey, TValue>(this IDictionary<TKey, TValue> dictionary,
TKey key, Func<TValue> creator)
parameter | description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
dictionary | The dictionary. |
key | The key. |
creator | Used to create a new value if necessary |
The new or existing value.