CollectionExtensions.TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) Método
Definição
Tenta adicionar o key
e o value
especificados ao dictionary
.Tries to add the specified key
and value
to the 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.The type of the keys in the dictionary.
- TValue
O tipo dos valores no dicionário.The type of the values in the dictionary.
Parâmetros
- dictionary
- IDictionary<TKey,TValue>
Um dicionário com chaves do tipo TKey
e valores do tipo TValue
.A dictionary with keys of type TKey
and values of type TValue
.
- key
- TKey
A chave do valor a ser adicionado.The key of the value to add.
- value
- TValue
O valor a ser adicionado.The value to add.
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.true
when the key
and value
are successfully added to the dictionary
; false
when the dictionary
already contains the specified key
, in which case nothing gets added.
Exceções
dictionary
é null
.dictionary
is null
.