DictionaryExt.GetOrAddValue(TKey, TValue) Method
Gets a given value defined by a key in a dictionary. If the key is not found, it is added and the value is given the default value.
Namespace: UltimateXR.Extensions.System.Collections
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0
Syntax
C#
public static TValue GetOrAddValue<TKey, TValue>(
this IDictionary<TKey, TValue> self,
TKey key
)
where TValue : new()
Parameters
- self
- Type: System.Collections.Generic.IDictionary(TKey, TValue)
Dictionary - key
- Type: TKey
Key to look for
Type Parameters
- TKey
- Key type
- TValue
- Value type
Return Value
Type: TValue
Value in the dictionary. If the key doesn’t exist it will be added and the return value will be the default value
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IDictionary(TKey, TValue). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also
Reference
DictionaryExt Class
UltimateXR.Extensions.System.Collections Namespace