ImmutableDictionary.GetValueOrDefault 方法

定義

多載

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

如果字典中存在相符的索引鍵,就會取得指定索引鍵的值。

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

如果字典中存在相符的索引鍵,就會取得指定索引鍵的值。

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

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

如果字典中存在相符的索引鍵,就會取得指定索引鍵的值。

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

類型參數

TKey

索引鍵的類型。

TValue

值的型別。

參數

dictionary
IImmutableDictionary<TKey,TValue>

要從中擷取值的字典。

key
TKey

要搜尋的索引鍵。

defaultValue
TValue

如果字典中找不到相符的索引鍵時所傳回的預設值。

傳回

TValue

索引鍵的值,或者,如果找不到相符的索引鍵,則為 defaultValue

適用於

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

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

如果字典中存在相符的索引鍵,就會取得指定索引鍵的值。

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

類型參數

TKey

索引鍵的類型。

TValue

值的類型。

參數

dictionary
IImmutableDictionary<TKey,TValue>

要從中擷取值的字典。

key
TKey

要搜尋的索引鍵。

傳回

TValue

索引鍵的值,或者,如果找不到相符的索引鍵,則為 default(TValue)

適用於