CollectionExtensions.TryAdd<TKey,TValue> Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Tenta adicionar o key e o value especificados ao 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
Parâmetros de tipo
- TKey
O tipo das chaves no dicionário.
- TValue
O tipo dos valores no dicionário.
Parâmetros
- dictionary
- IDictionary<TKey,TValue>
Um dicionário com chaves do tipo TKey e valores do tipo TValue.
- key
- TKey
A chave do valor a ser adicionado.
- value
- TValue
O valor a ser adicionado.
Retornos
true quando o key e o value são adicionados com êxito ao dictionary; false quando o dictionary já contém o key especificado e nada é adicionado.
Exceções
dictionary é null.