DictionaryExtensionsGetValueOrDefaultTKey, TValue Method (IDictionaryTKey, TValue, TKey) |
Gets a value from a dictionary. If they value is not there, adds the default value to the dictionary and returns that.
Not thread safe because it can add items to the dictionary.
Namespace: Bio.UtilAssembly: Bio.Core (in Bio.Core.dll) Version: 2.0.0.1 (2.0.0.1)
Syntax public static TValue GetValueOrDefault<TKey, TValue>(
this IDictionary<TKey, TValue> dictionary,
TKey key
)
where TValue : new()
<ExtensionAttribute>
Public Shared Function GetValueOrDefault(Of TKey, TValue As New) (
dictionary As IDictionary(Of TKey, TValue),
key As TKey
) As TValue
public:
[ExtensionAttribute]
generic<typename TKey, typename TValue>
where TValue : gcnew()
static TValue GetValueOrDefault(
IDictionary<TKey, TValue>^ dictionary,
TKey key
)
[<ExtensionAttribute>]
static member GetValueOrDefault :
dictionary : IDictionary<'TKey, 'TValue> *
key : 'TKey -> 'TValue when 'TValue : new()
Parameters
- dictionary
- Type: System.Collections.GenericIDictionaryTKey, TValue
The dictionary - key
- Type: TKey
The key of the value to retrieve.
Type Parameters
- TKey
- The type of the dictionary's key
- TValue
- The type of the dictionary's value
Return Value
Type:
TValueA value for this key.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IDictionaryTKey,
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