Compartilhar via


CollectionsMarshal.GetValueRefOrAddDefault<TKey,TValue> Método

Definição

Obtém uma referência a um TValue no dicionário especificado, adicionando uma nova entrada com um valor padrão se a chave não existir.

public:
generic <typename TKey, typename TValue>
 static TValue % GetValueRefOrAddDefault(System::Collections::Generic::Dictionary<TKey, TValue> ^ dictionary, TKey key, [Runtime::InteropServices::Out] bool % exists);
public static ref TValue? GetValueRefOrAddDefault<TKey,TValue> (System.Collections.Generic.Dictionary<TKey,TValue> dictionary, TKey key, out bool exists);
static member GetValueRefOrAddDefault : System.Collections.Generic.Dictionary<'Key, 'Value> * 'Key * bool -> 'Value
Public Shared Function GetValueRefOrAddDefault(Of TKey, TValue) (dictionary As Dictionary(Of TKey, TValue), key As TKey, ByRef exists As Boolean) 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 a referência.

key
TKey

A chave usada para pesquisa.

exists
Boolean

Quando esse método retorna, contém true se key já existia no dicionário e false se uma nova entrada foi adicionada.

Retornos

TValue

Uma referência a um TValue no dicionário especificado.

Comentários

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

Aplica-se a