CollectionExtensions.TryAdd<TKey,TValue> Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Tenta adicionar o especificado key e value 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 Genérico
- 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 de tipo TKey e valores de tipo TValue.
- key
- TKey
A chave do valor a acrescentar.
- value
- TValue
O valor a acrescentar.
Devoluções
true quando os key e value forem adicionados com sucesso ao dictionary; false quando o dictionary já contém o especificado key, caso em que nada é adicionado.
Exceções
dictionary é null.