# ITwig interface

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

```cs
public interface ITwig
```

Non-generic interface for tree twigs. ITwig is similar to IList but it allows for meta data to be stored in parallel with regular data.

**Derived types:** [Twig<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.twig-1.md)

## Properties

- [CommonMetaData](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/commonmetadata.md): Gets the common meta data in this twig. This means the meta data shared amongst all non-null items. Any conflicting meta data (i.e. identical name, different values) will be omitted from this result.
- [Constraint](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/constraint.md): Gets the type constraint for this twig. Since each [ITwig](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig.md) instance is some form of [Twig<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.twig-1.md), this property tells you what T is.
- [Flavour](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/flavour.md): Gets the type flavour of the T constraint.
- [ItemCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/itemcount.md): Gets the number of items in this twig that aren't considered null.
- [Items](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/items.md): Get an enumerator for all items in this twig.
- [LeafCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/leafcount.md): Gets the number of items in this twig, including nulls.
- [MetaCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/metacount.md): Gets the number of defined meta data palettes in this twig.
- [NonNullItems](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/nonnullitems.md): Get an enumerator for all non-null items in this twig.
- [NonNullPears](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/nonnullpears.md): Enumerate over all non-null item/meta data pears.
- [NullCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/nullcount.md): Gets the number of items in this twig that are nulls. Note: even when a twig contains ValueTypes, it may still have nulls.
- [Pears](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/pears.md): Enumerate over all item/meta data pears.
- [TightConstraint](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/tightconstraint.md): Gets the type which is common to all values stored in this twig. This is potentially quite an expensive property to call and its value is not cached internally. If the twig contains no values at all, the return value is somewhat undefined but will either be [object](https://learn.microsoft.com/dotnet/api/system.object) or [ITwig.Constraint](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/constraint.md).

## Indexers

- [this[]](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/item.md): Gets the item/data pear at the given index.

## Methods

- [Apply](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/apply.md): Apply an expression to all elements in this twig. For an expression to be successful it needs to not throw exceptions and have a return type that is compatible with the underlying type of this twig.
- [Cast](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/cast.md): (2 overloads) Cast this twig to a [Twig<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.twig-1.md) type. This will only work if all non-null items are of the given type.
- [ClearMetaData](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/clearmetadata.md): Create a new twig with the same items but with no meta data.
- [Expand](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/expand.md): Expand this twig until the count is equal to the target count. This functionality is the basis for LongestList matching.
- [Format](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/format.md): (2 overloads) Format the items and/or data in this twig.
- [ItemAt](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/itemat.md): Gets the item at the given index.
- [Map](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/map.md): Reorder the items in this twig based on an index map.
- [MergeMetaData](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/mergemetadata.md): (2 overloads) Merge all meta data from another twig.
- [MetaAt](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/metaat.md): Gets the meta data at the given index.
- [NullAt](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/nullat.md): Gets whether the item at the given index is considered to be a null value.
- [RemoveAll](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/removeall.md): (2 overloads) Remove all items that pass a filter delegate.
- [RemoveAt](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/removeat.md): Remove the item at the given index.
- [RemoveIndices](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/removeindices.md): Remove all indices from this twig.
- [RemoveMetaData](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/removemetadata.md): Remove all meta values with the given names from this twig.
- [RemoveNulls](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/removenulls.md): Remove all null items from this twig.
- [RemovePattern](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/removepattern.md): Remove all items that are represented by a boolean pattern.
- [RemoveRange](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/removerange.md): Remove a range of items.
- [Reverse](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/reverse.md): Reverse the order of all items in this twig.
- [Shrink](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/shrink.md): Shrink this twig until the count is equal to the target count. This functionality is the basis for ShortestList matching.
- [Sort](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/sort.md): (4 overloads) Sort all items using a key array of doubles.
- [ToMetaArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/tometaarray.md): Copy the meta data (if any) to an array.
- [ToNullArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/tonullarray.md): Copy the null data (if any) to an array. This method may return null if there is no null data.
- [ToPearArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/topeararray.md): Create an array of item/data pears.
- [TryConvert<TQ>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/tryconvert.md): (2 overloads) Try and convert this twig into another using the set of centrally registered conversion delegates.
- [TypeAt](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/typeat.md): Gets the type of the item at the given index.
- [TypeName](https://developer.rhino3d.com/api/gh2/type/grasshopper2.data.itwig/typename.md): (2 overloads) Gets the user friendly type name of the twig type constraint.
