CollectionsMarshal.GetValueRefOrAddDefault<TKey,TValue> Metoda

Definicja

Pobiera odwołanie do elementu TValue w określonym słowniku, dodając nowy wpis z wartością domyślną, jeśli klucz nie istnieje.

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

Parametry typu

TKey

Typ klucza.

TValue

Typ wartości.

Parametry

dictionary
Dictionary<TKey,TValue>

Słownik umożliwiający pobranie odwołania do TValue elementu z.

key
TKey

Klucz używany do wyszukiwania.

exists
Boolean

Gdy ta metoda zostanie zwrócona, zawiera true wartość , jeśli key już istniała w słowniku i false czy dodano nowy wpis.

Zwraca

TValue

Odwołanie do elementu TValue w określonym słowniku.

Uwagi

Elementy nie powinny być dodawane do ani usuwane z elementu , podczas Dictionary<TKey,TValue> gdy odwołanie TValue jest używane.

Dotyczy