DictionaryExtensions.GetValueOrDefault<TKey,TValue> メソッド

定義

指定したキーに関連付けられている値を取得します。

public static TValue GetValueOrDefault<TKey,TValue> (this System.Collections.Generic.IDictionary<TKey,TValue> dictionary, TKey key, TValue defaultValue = default);
static member GetValueOrDefault : System.Collections.Generic.IDictionary<'Key, 'Value> * 'Key * 'Value -> 'Value
<Extension()>
Public Function GetValueOrDefault(Of TKey, TValue) (dictionary As IDictionary(Of TKey, TValue), key As TKey, Optional defaultValue As TValue = Nothing) As TValue

型パラメーター

TKey

キー パラメーターの型。

TValue

値パラメーターの型。

パラメーター

dictionary
IDictionary<TKey,TValue>

指定したキーを含むディクショナリ。

key
TKey

値を取得する対象のキー。

defaultValue
TValue

value パラメーターの型の既定値。

戻り値

TValue

キーが見つかった場合は、指定したキーに関連付けられている値。それ以外の場合は、value パラメーターの型の既定値。

適用対象