# CollectionExtensionMethods class

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

```cs
public static class CollectionExtensionMethods
```

Provides extension methods for enumerable collections.

## Methods

- [AddFlexible](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.collectionextensionmethods/addflexible.md): (2 overloads, static) Add a (possibly) hierarchical layer.
- [CommonValue<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.collectionextensionmethods/commonvalue.md): (3 overloads, static) Either return the value that all elements in the collection have or null.
- [FindFlexible](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.collectionextensionmethods/findflexible.md): (2 overloads, static) Search for a layer first by full path and then by name.
- [Toggle<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.collectionextensionmethods/toggle.md): (static) Remove an element from a hashset if it exists, or add it if it doesn't.
- [ToInstanceIdSet](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.collectionextensionmethods/toinstanceidset.md): (static) Collect the instance IDs of all objects and subobjects in a collection into a hash set.
- [TrueForSome<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.collectionextensionmethods/trueforsome.md): (static) Test whether a predicate holds for any of the values in a collection.
