TryAdd()

System::Text::Json::JsonCollectionExtensions::TryAdd(const TCollection&, const TKey&, const TValue&) function

Attempts to add the specified key and value to the dictionary, returning true on success.

template<typename TCollection,typename TKey,typename TValue> bool System::Text::Json::JsonCollectionExtensions::TryAdd(const TCollection &dictionary, const TKey &key, const TValue &value)

Template parameters

ParameterDescription
TCollectionThe dictionary-like collection type.
TKeyThe key type.
TValueThe value type.

Arguments

ParameterTypeDescription
dictionaryconst TCollection&The dictionary to add the pair to.
keyconst TKey&The key to add.
valueconst TValue&The value to add.

Return Value

True if the pair was added, false if the key already existed.

See Also