ImmutableDictionary<TKey, TValue> Class
Represents an immutable, unordered collection of keys and values.
NuGet package: System.Collections.Immutable (about immutable collections and how to install)
Assembly: System.Collections.Immutable (in System.Collections.Immutable.dll)
generic<typename TKey, typename TValue> [DefaultMemberAttribute("Item")] [DebuggerDisplayAttribute("Count = {Count}")] public ref class ImmutableDictionary sealed : IImmutableDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IDictionary, ICollection
Type Parameters
- TKey
The type of the keys in the dictionary.
- TValue
The type of the values in the dictionary.
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of key/value pairs in the immutable dictionary. |
![]() | IsEmpty | Gets a value that indicates whether this instance of the immutable dictionary is empty. |
![]() | Item[TKey] | Gets the TValue associated with the specified key. |
![]() | KeyComparer | Gets the key comparer for the immutable dictionary. |
![]() | Keys | Gets the keys in the immutable dictionary. |
![]() | ValueComparer | Gets the value comparer used to determine whether values are equal. |
![]() | Values | Gets the values in the immutable dictionary. |
| Name | Description | |
|---|---|---|
![]() | Add(TKey, TValue) | Adds an element with the specified key and value to the immutable dictionary. |
![]() | AddRange(IEnumerable<KeyValuePair<TKey, TValue>>^) | Adds the specified key/value pairs to the immutable dictionary. |
![]() | Clear() | Retrieves an empty immutable dictionary that has the same ordering and key/value comparison rules as this dictionary instance. |
![]() | Contains(KeyValuePair<TKey, TValue>) | Determines whether this immutable dictionary contains the specified key/value pair. |
![]() | ContainsKey(TKey) | Determines whether the immutable dictionary contains an element with the specified key. |
![]() | ContainsValue(TValue) | Determines whether the immutable dictionary contains an element with the specified value. |
![]() | Equals(Object^) | (Inherited from Object.) |
![]() | GetEnumerator() | Returns an enumerator that iterates through the immutable dictionary. |
![]() | GetHashCode() | (Inherited from Object.) |
![]() | GetType() | (Inherited from Object.) |
![]() | Remove(TKey) | Removes the element with the specified key from the immutable dictionary. |
![]() | RemoveRange(IEnumerable<TKey>^) | Removes the elements with the specified keys from the immutable dictionary. |
![]() | SetItem(TKey, TValue) | Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key. |
![]() | SetItems(IEnumerable<KeyValuePair<TKey, TValue>>^) | Sets the specified key/value pairs in the immutable dictionary, possibly overwriting existing values for the keys. |
![]() | ToBuilder() | Creates an immutable dictionary with the same contents as this dictionary that can be efficiently mutated across multiple operations by using standard mutable interfaces. |
![]() | ToString() | (Inherited from Object.) |
![]() | TryGetKey(TKey, TKey%) | Determines whether this dictionary contains a specified key. |
![]() | TryGetValue(TKey, TValue%) | Gets the value associated with the specified key. |
![]() | WithComparers(IEqualityComparer<TKey>^) | Gets an instance of the immutable dictionary that uses the specified key comparer. |
![]() | WithComparers(IEqualityComparer<TKey>^, IEqualityComparer<TValue>^) | Gets an instance of the immutable dictionary that uses the specified key and value comparers. |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection<KeyValuePair<TKey, TValue>>::Add(KeyValuePair<TKey, TValue>) | |
![]() ![]() | ICollection<KeyValuePair<TKey, TValue>>::Clear() | |
![]() ![]() | ICollection<KeyValuePair<TKey, TValue>>::CopyTo(array<KeyValuePair<TKey, TValue>>^, Int32) | |
![]() ![]() | ICollection<KeyValuePair<TKey, TValue>>::Remove(KeyValuePair<TKey, TValue>) | |
![]() ![]() | IDictionary<TKey, TValue>::Add(TKey, TValue) | Adds an element with the provided key and value to the immutable dictionary. |
![]() ![]() | IDictionary<TKey, TValue>::Remove(TKey) | Removes the element with the specified key from the immutable dictionary. |
![]() ![]() | IEnumerable<KeyValuePair<TKey, TValue>>::GetEnumerator() | |
![]() ![]() | ICollection::CopyTo(Array^, Int32) | Copies the elements of the dictionary to an array, starting at a particular array index. |
![]() ![]() | IDictionary::Add(Object^, Object^) | Adds an element with the provided key and value to the immutable dictionary object. |
![]() ![]() | IDictionary::Clear() | Clears this instance. |
![]() ![]() | IDictionary::Contains(Object^) | Determines whether the immutable dictionary object contains an element with the specified key. |
![]() ![]() | IDictionary::GetEnumerator() | Returns an IDictionaryEnumerator object for the immutable dictionary object. |
![]() ![]() | IDictionary::Remove(Object^) | Removes the element with the specified key from the immutable dictionary object. |
![]() ![]() | IEnumerable::GetEnumerator() | Returns an enumerator that iterates through a collection. |
![]() ![]() | IImmutableDictionary<TKey, TValue>::Add(TKey, TValue) | Adds an element with the specified key and value to the immutable dictionary. |
![]() ![]() | IImmutableDictionary<TKey, TValue>::AddRange(IEnumerable<KeyValuePair<TKey, TValue>>^) | Adds the specified key/value pairs to the immutable dictionary. |
![]() ![]() | IImmutableDictionary<TKey, TValue>::Clear() | Retrieves an empty dictionary that has the same ordering and key/value comparison rules as this dictionary instance. |
![]() ![]() | IImmutableDictionary<TKey, TValue>::Remove(TKey) | Removes the element with the specified key from the immutable dictionary. |
![]() ![]() | IImmutableDictionary<TKey, TValue>::RemoveRange(IEnumerable<TKey>^) | Removes the elements with the specified keys from the immutable dictionary. |
![]() ![]() | IImmutableDictionary<TKey, TValue>::SetItem(TKey, TValue) | Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key. |
![]() ![]() | IImmutableDictionary<TKey, TValue>::SetItems(IEnumerable<KeyValuePair<TKey, TValue>>^) | Sets the specified key/value pairs in the immutable dictionary, possibly overwriting existing values for the keys. |
![]() ![]() | ICollection<KeyValuePair<TKey, TValue>>::IsReadOnly | |
![]() ![]() | IDictionary<TKey, TValue>::Item[TKey] | |
![]() ![]() | IDictionary<TKey, TValue>::Keys | |
![]() ![]() | IDictionary<TKey, TValue>::Values | |
![]() ![]() | ICollection::IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized (thread safe). |
![]() ![]() | ICollection::SyncRoot | Gets an object that can be used to synchronize access to the ICollection. |
![]() ![]() | IDictionary::IsFixedSize | Gets a value indicating whether the IDictionary object has a fixed size. |
![]() ![]() | IDictionary::IsReadOnly | Gets a value indicating whether the ICollection<T> is read-only. |
![]() ![]() | IDictionary::Item[Object^] | Gets or sets the element with the specified key. |
![]() ![]() | IDictionary::Keys | Gets an ICollection<T> containing the keys of the IDictionary<TKey, TValue>. |
![]() ![]() | IDictionary::Values | Gets an ICollection<T> containing the values in the IDictionary<TKey, TValue>. |
When you manipulate an immutable dictionary a copy of the original dictionary is made, manipulations applied and a new immutable dictionary is returned.
This type is thread safe.






