CollectionsMarshal.GetValueRefOrAddDefault 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
GetValueRefOrAddDefault<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey, Boolean)
public:
generic <typename TKey, typename TValue, typename TAlternateKey>
static TValue % GetValueRefOrAddDefault(System::Collections::Generic::Dictionary<TKey, TValue>::AlternateLookup<TAlternateKey> dictionary, TAlternateKey key, [Runtime::InteropServices::Out] bool % exists);
public static ref TValue? GetValueRefOrAddDefault<TKey,TValue,TAlternateKey> (System.Collections.Generic.Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey> dictionary, TAlternateKey key, out bool exists);
static member GetValueRefOrAddDefault : System.Collections.Generic.Dictionary<'Key, 'Value>.AlternateLookup<'AlternateKey> * 'AlternateKey * bool -> 'Value
Public Shared Function GetValueRefOrAddDefault(Of TKey, TValue, TAlternateKey) (dictionary As Dictionary(Of TKey, TValue).AlternateLookup(Of TAlternateKey), key As TAlternateKey, ByRef exists As Boolean) As TValue
類型參數
- TKey
- TValue
- TAlternateKey
參數
- key
- TAlternateKey
- exists
- Boolean
傳回
TValue
適用於
GetValueRefOrAddDefault<TKey,TValue>(Dictionary<TKey,TValue>, TKey, Boolean)
取得指定字典中 之 TValue
的參考,如果索引鍵不存在,則加入具有預設值的新專案。
public:
generic <typename TKey, typename TValue>
static TValue % GetValueRefOrAddDefault(System::Collections::Generic::Dictionary<TKey, TValue> ^ dictionary, TKey key, [Runtime::InteropServices::Out] bool % exists);
public static ref TValue? GetValueRefOrAddDefault<TKey,TValue> (System.Collections.Generic.Dictionary<TKey,TValue> dictionary, TKey key, out bool exists);
static member GetValueRefOrAddDefault : System.Collections.Generic.Dictionary<'Key, 'Value> * 'Key * bool -> 'Value
Public Shared Function GetValueRefOrAddDefault(Of TKey, TValue) (dictionary As Dictionary(Of TKey, TValue), key As TKey, ByRef exists As Boolean) As TValue
類型參數
- TKey
索引鍵的類型。
- TValue
值的型別。
參數
- dictionary
- Dictionary<TKey,TValue>
要從中取得參考的 TValue
字典。
- key
- TKey
用於查閱的索引鍵。
- exists
- Boolean
當這個方法傳回時,如果true
key
字典中已經存在,則包含 ,如果false
已加入新專案,則包含 。
傳回
TValue
指定字典中的 參考 TValue
。
備註
當 ref TValue
正在使用時,不應將專案新增至 或從 Dictionary<TKey,TValue> 中移除。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應