ImmutableDictionary.GetValueOrDefault ImmutableDictionary.GetValueOrDefault ImmutableDictionary.GetValueOrDefault ImmutableDictionary.GetValueOrDefault Method

定义

重载

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

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

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

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

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

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

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

键的类型。The type of the key.

TValue

值的类型。The type of the value.

参数

dictionary
IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue>

要从中检索值的字典。The dictionary to retrieve the value from.

key
TKey TKey TKey TKey

要搜索的键。The key to search for.

defaultValue
TValue TValue TValue TValue

在字典中找不到匹配键时返回的默认值。The default value to return if no matching key is found in the dictionary.

返回

TValue TValue TValue TValue

该键的值;如果找不到匹配的键,则为 defaultValueThe value for the key, or defaultValue if no matching key was found.

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

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

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);
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

键的类型。The type of the key.

TValue

值的类型。The type of the value.

参数

dictionary
IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue>

要从中检索值的字典。The dictionary to retrieve the value from.

key
TKey TKey TKey TKey

要搜索的键。The key to search for.

返回

TValue TValue TValue TValue

该键的值;如果找不到匹配的键,则为 default(TValue)The value for the key, or default(TValue) if no matching key was found.

适用于