CollectionExtensions.TryAdd<TKey,TValue> Método

Definición

Intenta agregar el especificado key y value al dictionaryobjeto .

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

Parámetros de tipo

TKey

Tipo de las claves del diccionario.

TValue

Tipo de los valores del diccionario.

Parámetros

dictionary
IDictionary<TKey,TValue>

Diccionario con claves de tipo TKey y valores de tipo TValue.

key
TKey

Clave del valor que se va a agregar.

value
TValue

Valor que se va a agregar.

Devoluciones

true cuando y keyvalue se agregan correctamente a dictionary; false cuando dictionary ya contiene el objeto especificado key, en cuyo caso no se agrega nada.

Excepciones

dictionary es null.

Se aplica a