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)
Namespace: System.Collections.Immutable
Assembly: System.Collections.Immutable (in System.Collections.Immutable.dll)
[<Sealed>] type ImmutableDictionary<'TKey, 'TValue> = class interface IImmutableDictionary<'TKey, 'TValue> interface IReadOnlyDictionary<'TKey, 'TValue> interface IReadOnlyCollection<KeyValuePair<'TKey, 'TValue>> interface IDictionary<'TKey, 'TValue> interface ICollection<KeyValuePair<'TKey, 'TValue>> interface IEnumerable<KeyValuePair<'TKey, 'TValue>> interface IDictionary interface ICollection interface IEnumerable end
Type Parameters
- TKey
The type of the keys in the dictionary.
- TValue
The type of the values in the dictionary.
The ImmutableDictionary(TKey, TValue) type exposes the following members.
| 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 | 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 | Adds an element with the specified key and value to the immutable dictionary. |
![]() | AddRange | 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 | Determines whether this immutable dictionary contains the specified key/value pair. |
![]() | ContainsKey | Determines whether the immutable dictionary contains an element with the specified key. |
![]() | ContainsValue | Determines whether the immutable dictionary contains an element with the specified value. |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | GetEnumerator | Returns an enumerator that iterates through the immutable dictionary. |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Remove | Removes the element with the specified key from the immutable dictionary. |
![]() | RemoveRange | Removes the elements with the specified keys from the immutable dictionary. |
![]() | SetItem | Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key. |
![]() | SetItems | 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 | Returns a string that represents the current object. (Inherited from Object.) |
![]() | TryGetKey | Determines whether this dictionary contains a specified key. |
![]() | TryGetValue | 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 | |
|---|---|---|
![]() | ToImmutableArray(KeyValuePair(TKey, TValue)) | [This topic is preliminary and is subject to change.] Creates an immutable array from the specified collection. (Defined by ImmutableArray.) |
![]() | ToImmutableDictionary(KeyValuePair(TKey, TValue), TKey)(Func(KeyValuePair(TKey, TValue), TKey)) | Overloaded. Constructs an immutable dictionary from an existing collection of elements, applying a transformation function to the source keys. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(KeyValuePair(TKey, TValue), TKey)(Func(KeyValuePair(TKey, TValue), TKey), IEqualityComparer(TKey)) | Overloaded. Constructs an immutable dictionary based on some transformation of a sequence. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(KeyValuePair(TKey, TValue), TKey, TValue)(Func(KeyValuePair(TKey, TValue), TKey), Func(KeyValuePair(TKey, TValue), TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable dictionary of its contents. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(KeyValuePair(TKey, TValue), TKey, TValue)(Func(KeyValuePair(TKey, TValue), TKey), Func(KeyValuePair(TKey, TValue), TValue), IEqualityComparer(TKey)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key comparer. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(KeyValuePair(TKey, TValue), TKey, TValue)(Func(KeyValuePair(TKey, TValue), TKey), Func(KeyValuePair(TKey, TValue), TValue), IEqualityComparer(TKey), IEqualityComparer(TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key and value comparers. (Defined by ImmutableDictionary.) |
![]() | ToImmutableHashSet(KeyValuePair(TKey, TValue))() | Overloaded. Enumerates a sequence and produces an immutable hash set of its contents. (Defined by ImmutableHashSet.) |
![]() | ToImmutableHashSet(KeyValuePair(TKey, TValue))(IEqualityComparer(KeyValuePair(TKey, TValue))) | Overloaded. Enumerates a sequence, produces an immutable hash set of its contents, and uses the specified equality comparer for the set type. (Defined by ImmutableHashSet.) |
![]() | ToImmutableList(KeyValuePair(TKey, TValue)) | Enumerates a sequence and produces an immutable list of its contents. (Defined by ImmutableList.) |
![]() | ToImmutableSortedDictionary(KeyValuePair(TKey, TValue), TKey, TValue)(Func(KeyValuePair(TKey, TValue), TKey), Func(KeyValuePair(TKey, TValue), TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents. (Defined by ImmutableSortedDictionary.) |
![]() | ToImmutableSortedDictionary(KeyValuePair(TKey, TValue), TKey, TValue)(Func(KeyValuePair(TKey, TValue), TKey), Func(KeyValuePair(TKey, TValue), TValue), IComparer(TKey)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key comparer. (Defined by ImmutableSortedDictionary.) |
![]() | ToImmutableSortedDictionary(KeyValuePair(TKey, TValue), TKey, TValue)(Func(KeyValuePair(TKey, TValue), TKey), Func(KeyValuePair(TKey, TValue), TValue), IComparer(TKey), IEqualityComparer(TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key and value comparers. (Defined by ImmutableSortedDictionary.) |
![]() | ToImmutableSortedSet(KeyValuePair(TKey, TValue))() | Overloaded. Enumerates a sequence and produces an immutable sorted set of its contents. (Defined by ImmutableSortedSet.) |
![]() | ToImmutableSortedSet(KeyValuePair(TKey, TValue))(IComparer(KeyValuePair(TKey, TValue))) | Overloaded. Enumerates a sequence, produces an immutable sorted set of its contents, and uses the specified comparer. (Defined by ImmutableSortedSet.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection(KeyValuePair(TKey, TValue)).Add | Adds the specified value to the collection. |
![]() ![]() | IDictionary(TKey, TValue).Add | Adds an element with the provided key and value to the immutable dictionary. |
![]() ![]() | IDictionary.Add | Adds an element with the provided key and value to the immutable dictionary object. |
![]() ![]() | ICollection(KeyValuePair(TKey, TValue)).Clear | Removes all the items from the collection. |
![]() ![]() | IDictionary.Clear | Clears this instance. |
![]() ![]() | IDictionary.Contains | Determines whether the immutable dictionary object contains an element with the specified key. |
![]() ![]() | ICollection(KeyValuePair(TKey, TValue)).CopyTo | Copies the elements of the collection to an Array, starting at a particular Array index. |
![]() ![]() | ICollection.CopyTo | Copies the elements of the dictionary to an array, starting at a particular array index. |
![]() ![]() | IEnumerable(KeyValuePair(TKey, TValue)).GetEnumerator | Returns an enumerator that iterates through the collection. |
![]() ![]() | IDictionary.GetEnumerator | Returns an IDictionaryEnumerator object for the immutable dictionary object. |
![]() ![]() | IEnumerable.GetEnumerator | Returns an enumerator that iterates through a collection. |
![]() ![]() | IDictionary.IsFixedSize | Gets a value indicating whether the immutable dictionary object has a fixed size. |
![]() ![]() | ICollection(KeyValuePair(TKey, TValue)).IsReadOnly | Gets a value indicating whether the immutable dictionary is read-only. |
![]() ![]() | IDictionary.IsReadOnly | Gets a value indicating whether the immutable dictionary is read-only. |
![]() ![]() | ICollection.IsSynchronized | Gets a value indicating whether access to the immutable dictionary is synchronized (thread safe). |
![]() ![]() | IDictionary(TKey, TValue).Item | Gets or sets the element with the specified key. |
![]() ![]() | IDictionary.Item | Gets or sets the element with the specified key. |
![]() ![]() | IDictionary(TKey, TValue).Keys | Gets a collection containing the keys of the immutable dictionary. |
![]() ![]() | IDictionary.Keys | Gets an ICollection(T) object containing the keys of the immutable dictionary. |
![]() ![]() | ICollection(KeyValuePair(TKey, TValue)).Remove | Removes the first occurrence of a specific object from the immutable dictionary. |
![]() ![]() | IDictionary(TKey, TValue).Remove | Removes the element with the specified key from the immutable dictionary. |
![]() ![]() | IDictionary.Remove | Removes the element with the specified key from the immutable dictionary object. |
![]() ![]() | ICollection.SyncRoot | Gets an object that can be used to synchronize access to the immutable dictionary. |
![]() ![]() | IDictionary(TKey, TValue).Values | Gets a collection containing the values of the immutable dictionary. |
![]() ![]() | IDictionary.Values | Gets an ICollection(T) object containing the values in the immutable dictionary. |
![]() ![]() | IImmutableDictionary(TKey, TValue).Add | Adds an element with the specified key and value to the immutable dictionary. |
![]() ![]() | IImmutableDictionary(TKey, TValue).AddRange | 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 | Removes the element with the specified key from the immutable dictionary. |
![]() ![]() | IImmutableDictionary(TKey, TValue).RemoveRange | Removes the elements with the specified keys from the immutable dictionary. |
![]() ![]() | IImmutableDictionary(TKey, TValue).SetItem | Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key. |
![]() ![]() | IImmutableDictionary(TKey, TValue).SetItems | Sets the specified key/value pairs in the immutable dictionary, possibly overwriting existing values for the keys. |
Show:

