CollectionsMarshal.GetValueRefOrNullRef<TKey,TValue> 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取对中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
对 .TValue
Dictionary<TKey,TValue>中dictionary
不存在的引用或引用null
。
注解
不应在引用正在使用时TValue
添加或删除Dictionary<TKey,TValue>项。
可以通过调用来System.Runtime.CompilerServices.Unsafe.IsNullRef<T>(T)检测 refnull
。