CollectionExtensions.TryAdd<TKey,TValue> Metoda

Definicja

Próbuje dodać określony key element i value do .dictionary

public:
generic <typename TKey, typename TValue>
[System::Runtime::CompilerServices::Extension]
 static bool TryAdd(System::Collections::Generic::IDictionary<TKey, TValue> ^ dictionary, TKey key, TValue value);
public static bool TryAdd<TKey,TValue> (this System.Collections.Generic.IDictionary<TKey,TValue> dictionary, TKey key, TValue value);
static member TryAdd : System.Collections.Generic.IDictionary<'Key, 'Value> * 'Key * 'Value -> bool
<Extension()>
Public Function TryAdd(Of TKey, TValue) (dictionary As IDictionary(Of TKey, TValue), key As TKey, value As TValue) As Boolean

Parametry typu

TKey

Typ kluczy w słowniku.

TValue

Typ wartości w słowniku.

Parametry

dictionary
IDictionary<TKey,TValue>

Słownik z kluczami typu TKey i wartościami typu TValue.

key
TKey

Klucz wartości do dodania.

value
TValue

Wartość do dodania.

Zwraca

true gdy element key i value zostanie pomyślnie dodany do dictionaryelementu ; false gdy dictionary obiekt zawiera już określony keyelement , w tym przypadku nic nie zostanie dodane.

Wyjątki

dictionary to null.

Dotyczy