# Plurality<T> class

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

```cs
public sealed class Plurality<T>
```

Represents a collection of values, some of which may be identical. This class is used for 'varies' UI to keep track of multiple states.

**Type parameters:**

- `T`

## Constructors

- [Plurality<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/ctor.md): Create a new plurality with an equality comparer.

## Properties

- [AllValues](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/allvalues.md): Enumerate over all values in this plurality, including repeats. Enumeration starts with the most common value.
- [Average](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/average.md): Gets the average of this collection. This value makes no sense if Count = 0.
- [Count](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/count.md): Gets the number of unique values.
- [State](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/state.md): Gets the state of the current plurality.
- [ValencePairs](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/valencepairs.md): Iterate over all values and valences, in order of high valence to low.
- [Values](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/values.md): Enumerate over all unique values in this plurality. Enumeration starts with the most common value.

## Indexers

- [this[]](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/item.md): Gets the value at the given index. The index must be between zero and Count.

## Methods

- [AppendToMenu](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/appendtomenu.md): Create a context menu for all unique values in this plurality.
- [Assign](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/assign.md): (2 overloads) Assign a new plurality.
- [Clear](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/clear.md): Clear all values. This is synonymous with calling Assign(null);

## Events

- [Changed](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.plurality-1/changed.md): Raised whenever the state or contents of this plurality collection changes.
