# MultiDictionary<TKey, TValue> class

Namespace: [Grasshopper2.Collections](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.collections.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public class MultiDictionary<TKey, TValue>
```

Provides a palette with multiple values per key. This class is not optimized for large overlaps of values.

**Type parameters:**

- `TKey`: Key type.
- `TValue`: Value type.

## Constructors

- [MultiDictionary<TKey, TValue>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/ctor.md): (4 overloads) Create a new MultiDictionary.

## Properties

- [ArrayPairs](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/arraypairs.md): Gets an enumerator for all key/valuearray pairs.
- [HighestValence](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/highestvalence.md): Gets the highest valence in this MultiDictionary.
- [KeyCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/keycount.md): Gets the number of keys stored in this MultiDictionary.
- [Keys](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/keys.md): Enumerate over all keys.
- [LowestValence](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/lowestvalence.md): Gets the lowest valence in this MultiDictionary.
- [ValueArrays](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/valuearrays.md): Enumerate over all value arrays.
- [ValueCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/valuecount.md): Gets the number of values stored in this MultiDictionary.
- [Values](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/values.md): Enumerate over all values.

## Indexers

- [this[]](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/item.md): Gets all items associated with a specific key.

## Methods

- [Add](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/add.md): Add a value to this MultiDictionary.
- [AddRange](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/addrange.md): Add values to this MultiDictionary.
- [Clear](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/clear.md): Clear the MultiDictionary.
- [ContainsKey](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/containskey.md): Test whether a specific key is defined.
- [KeyValence](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/keyvalence.md): Gets the number of values associated with the given key.
- [Remove](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/remove.md): (2 overloads) Remove a specific value associated with a specific key.
- [RemoveAll](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/removeall.md): Remove all occurences of a specific value.
- [RemoveListsByLength](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/removelistsbylength.md): Remove all entries that contain lists shorter than or longer than the specified limits.
- [TryGetAll](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/trygetall.md): Try to get all values associated with a specific key.
- [TryGetFirst](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/trygetfirst.md): Try to get the get the first value associated with a specific key.
- [TryGetOne](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/trygetone.md): Try to get a single value associated with the key. If the key has valence zero or higher than one, this method will return false.
- [ValencePairs](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.multidictionary-2/valencepairs.md): Gets all key/value pairs that are within some valence range.
