CollectionExtensions.TryAdd<TKey,TValue> Methode

Definitie

Probeert de opgegeven key en value aan de 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

Type parameters

TKey

Het type sleutels in de woordenlijst.

TValue

Het type van de waarden in de woordenlijst.

Parameters

dictionary
IDictionary<TKey,TValue>

Een woordenlijst met sleutels van het type TKey en de waarden van het type TValue.

key
TKey

De sleutel van de waarde die moet worden toegevoegd.

value
TValue

De waarde die moet worden toegevoegd.

Retouren

true wanneer de key en value zijn toegevoegd aan de dictionary; false wanneer het al de dictionary opgegeven keybevat , in welk geval niets wordt toegevoegd.

Uitzonderingen

dictionary is null.

Van toepassing op