Partilhar via


CollectionsMarshal.GetValueRefOrNullRef<TKey,TValue> Método

Definição

Obtém uma referência a um TValue no Dictionary<TKey,TValue> ou uma referência null se ele não existir no 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

Parâmetros de tipo

TKey

O tipo de uma chave.

TValue

O tipo de um valor.

Parâmetros

dictionary
Dictionary<TKey,TValue>

O dicionário para TValue o qual obter o ref.

key
TKey

A chave usada para pesquisa.

Retornos

TValue

Uma referência a um TValue no Dictionary<TKey,TValue> ou uma referência null se ele não existir no dictionary..

Comentários

Os itens não devem ser adicionados ou removidos do Dictionary<TKey,TValue> enquanto o ref TValue estiver em uso.

O ref null pode ser detectado chamando System.Runtime.CompilerServices.Unsafe.IsNullRef<T>(T).

Aplica-se a