CollectionExtensions.GetValueOrDefault メソッド

定義

オーバーロード

名前 説明
GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)

key内の指定したdictionaryに関連付けられた値の取得を試みます。

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)

key内の指定したdictionaryに関連付けられた値の取得を試みます。

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)

key内の指定したdictionaryに関連付けられた値の取得を試みます。

public:
generic <typename TKey, typename TValue>
[System::Runtime::CompilerServices::Extension]
 static TValue GetValueOrDefault(System::Collections::Generic::IReadOnlyDictionary<TKey, TValue> ^ dictionary, TKey key);
public static TValue GetValueOrDefault<TKey,TValue>(this System.Collections.Generic.IReadOnlyDictionary<TKey,TValue> dictionary, TKey key);
static member GetValueOrDefault : System.Collections.Generic.IReadOnlyDictionary<'Key, 'Value> * 'Key -> 'Value
<Extension()>
Public Function GetValueOrDefault(Of TKey, TValue) (dictionary As IReadOnlyDictionary(Of TKey, TValue), key As TKey) As TValue

型パラメーター

TKey

ディクショナリ内のキーの型。

TValue

ディクショナリ内の値の型。

パラメーター

dictionary
IReadOnlyDictionary<TKey,TValue>

TKey型のキーとTValue型の値を持つディクショナリ。

key
TKey

取得する値のキー。

返品

TValue

TValue インスタンス。 メソッドが成功すると、返されるオブジェクトは、指定した keyに関連付けられている値です。 メソッドが失敗すると、TValuedefault値が返されます。

例外

dictionarynullです。

適用対象

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)

key内の指定したdictionaryに関連付けられた値の取得を試みます。

public:
generic <typename TKey, typename TValue>
[System::Runtime::CompilerServices::Extension]
 static TValue GetValueOrDefault(System::Collections::Generic::IReadOnlyDictionary<TKey, TValue> ^ dictionary, TKey key, TValue defaultValue);
public static TValue GetValueOrDefault<TKey,TValue>(this System.Collections.Generic.IReadOnlyDictionary<TKey,TValue> dictionary, TKey key, TValue defaultValue);
static member GetValueOrDefault : System.Collections.Generic.IReadOnlyDictionary<'Key, 'Value> * 'Key * 'Value -> 'Value
<Extension()>
Public Function GetValueOrDefault(Of TKey, TValue) (dictionary As IReadOnlyDictionary(Of TKey, TValue), key As TKey, defaultValue As TValue) As TValue

型パラメーター

TKey

ディクショナリ内のキーの型。

TValue

ディクショナリ内の値の型。

パラメーター

dictionary
IReadOnlyDictionary<TKey,TValue>

TKey型のキーとTValue型の値を持つディクショナリ。

key
TKey

取得する値のキー。

defaultValue
TValue

指定したkeyに関連付けられた値がdictionaryで見つからない場合に返される既定値。

返品

TValue

TValue インスタンス。 メソッドが成功すると、返されるオブジェクトは、指定した keyに関連付けられている値です。 メソッドが失敗すると、 defaultValueが返されます。

例外

dictionarynullです。

適用対象