Table of Contents

AddOrUpdate Method

Definition

Namespace
Cuemon.Extensions.Collections.Generic
Assemblies
Cuemon.Extensions.Collections.Generic.dll
Source
src/Cuemon.Extensions.Collections.Generic/DictionaryExtensions.cs

AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)

Attempts to add or update an existing element with the provided key to the dictionary with the specified value.

public static void AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)

Parameters

dictionary IDictionary<TKey, TValue>

The IDictionary<TKey, TValue> to extend.

key TKey

The key of the element to add or update.

value TValue

The value of the element to add or update.

Type Parameters

TKey
TValue

Exceptions

ArgumentNullException

dictionary cannot be null -or- key cannot be null.