语言

CollectionsMarshal.GetValueRefOrNullRef 方法

定义

重载

名称 说明
GetValueRefOrNullRef<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey)

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

GetValueRefOrNullRef<TKey,TValue>(Dictionary<TKey,TValue>, TKey)

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

GetValueRefOrNullRef<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey)

Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs

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

public:
generic <typename TKey, typename TValue, typename TAlternateKey>
 static TValue % GetValueRefOrNullRef(System::Collections::Generic::Dictionary<TKey, TValue>::AlternateLookup<TAlternateKey> dictionary, TAlternateKey key);
public static ref TValue GetValueRefOrNullRef<TKey,TValue,TAlternateKey>(System.Collections.Generic.Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey> dictionary, TAlternateKey key) where TAlternateKey : allows ref struct;
static member GetValueRefOrNullRef : System.Collections.Generic.Dictionary<'Key, 'Value>.AlternateLookup<'AlternateKey> * 'AlternateKey -> 'Value
Public Shared Function GetValueRefOrNullRef(Of TKey, TValue, TAlternateKey) (dictionary As Dictionary(Of TKey, TValue).AlternateLookup(Of TAlternateKey), key As TAlternateKey) As TValue

类型参数

TKey

字典中键的类型。

TValue

字典中值的类型。

TAlternateKey

字典中查找的备用键的类型。

参数

dictionary
Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>

要从中获取 ref TValue 的字典。

key
TAlternateKey

用于查找的键。

返回

TValue

对 .TValue中不存在的Dictionary<TKey,TValue>引用或引用nulldictionary。

注解

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

可以通过调用来IsNullRef<T>(T)检测 refnull。

适用于

GetValueRefOrNullRef<TKey,TValue>(Dictionary<TKey,TValue>, TKey)

Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs

获取对中TValue或Dictionary<TKey,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>引用或引用nulldictionary。

注解

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

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

适用于