DictionaryUtility.GetOrAddValue<TKey,TValue> method (1 of 2)

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.

Return Value

The new or existing value.

See Also


DictionaryUtility.GetOrAddValue<TKey,TValue> method (2 of 2)

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

Return Value

The new or existing value.

See Also