共用方式為


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>

字典

key
TK

字典中的索引鍵

傳回

TV

如果字典中沒有索引鍵,則預設值為 。

適用於