Share via


DictionaryExtensions.GetOrDefault<TK,TV> Method

Definition

Gets a value by the given key.

public:
generic <typename TK, typename TV>
[System::Runtime::CompilerServices::Extension]
 static TV GetOrDefault(System::Collections::Generic::IDictionary<TK, TV> ^ dictionary, TK key);
public static TV GetOrDefault<TK,TV> (this System.Collections.Generic.IDictionary<TK,TV> dictionary, TK key);
static member GetOrDefault : System.Collections.Generic.IDictionary<'K, 'V> * 'K -> 'V
<Extension()>
Public Function GetOrDefault(Of TK, TV) (dictionary As IDictionary(Of TK, TV), key As TK) As TV

Type Parameters

TK

key type

TV

value type

Parameters

dictionary
IDictionary<TK,TV>

dictionary

key
TK

key in the dictionary

Returns

TV

default if key doesn't exist in the dictionary.

Applies to