CollectionsMarshal.GetValueRefOrNullRef<TKey,TValue> 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 中 的參考TValue
,如果 不存在於 中,null
則取得 參考dictionary
。Dictionary<TKey,TValue>
public:
generic <typename TKey, typename TValue>
static TValue % GetValueRefOrNullRef(System::Collections::Generic::Dictionary<TKey, TValue> ^ dictionary, TKey key);
public static ref TValue GetValueRefOrNullRef<TKey,TValue> (System.Collections.Generic.Dictionary<TKey,TValue> dictionary, TKey key);
static member GetValueRefOrNullRef : System.Collections.Generic.Dictionary<'Key, 'Value> * 'Key -> 'Value
Public Shared Function GetValueRefOrNullRef(Of TKey, TValue) (dictionary As Dictionary(Of TKey, TValue), key As TKey) As TValue
類型參數
- TKey
索引鍵的類型。
- TValue
值的型別。
參數
- dictionary
- Dictionary<TKey,TValue>
要從中取得 ref 的 TValue
字典。
- key
- TKey
用於查閱的索引鍵。
傳回
TValue
中 的參考TValue
,如果 不存在於 中dictionary
,則為 參考null
。Dictionary<TKey,TValue>
備註
當 ref TValue
正在使用時,不應從 新增或移除Dictionary<TKey,TValue>專案。
您可以呼叫 System.Runtime.CompilerServices.Unsafe.IsNullRef<T>(T)來偵測 refnull
。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應