DictionaryExtensions.GetOrDefault<TK,TV> 方法

定义

按给定键获取值。

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

类型参数

TK

密钥类型

TV

Value Type — 值类型

参数

dictionary
IDictionary<TK,TV>

dictionary

key
TK

字典中的键

返回

TV

如果字典中不存在键,则为默认值。

适用于