CollectionsMarshal.GetValueRefOrNullRef<TKey,TValue> 方法

定义

获取对中Dictionary<TKey,TValue>TValue引用的引用(如果该引用null不存在)。dictionary

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

对 .TValueDictionary<TKey,TValue>dictionary不存在的引用或引用null

注解

不应在引用正在使用时TValue添加或删除Dictionary<TKey,TValue>项。

可以通过调用来System.Runtime.CompilerServices.Unsafe.IsNullRef<T>(T)检测 refnull

适用于