ImmutableDictionary<TKey, TValue>.Add Method (TKey, TValue)

 

Adds an element with the specified key and value to the immutable dictionary.

Namespace:   System.Collections.Immutable
Assembly:  System.Collections.Immutable (in System.Collections.Immutable.dll)

public ImmutableDictionary<TKey, TValue> Add(
	TKey key,
	TValue value
)

Parameters

key
Type: TKey

The key of the element to add.

value
Type: TValue

The value of the element to add.

Return Value

Type: System.Collections.Immutable.ImmutableDictionary<TKey, TValue>

A new immutable dictionary that contains the additional key/value pair.

Exception Condition
ArgumentException

The given key already exists in the dictionary but has a different value.

If the given key/value pair already exists in the dictionary, the existing instance of the dictionary is returned.

Return to top
Show: