# ArrayEx 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 ArrayEx
```

Extension methods for T[]

## Methods

- [AllElementsEqual<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/allelementsequal.md): (2 overloads, static) Test whether all entries in an array are equal to a given value.
- [AllNull<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/allnull.md): (static) Tests whether all pears are null.
- [AnyMeta<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/anymeta.md): (static) Tests whether any of the pears contain meta data.
- [AnyNull<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/anynull.md): (static) Tests whether any of the pears are null.
- [Append<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/append.md): (2 overloads, static) Append a collection of items to the end of this array.
- [Chain<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/chain.md): (static) Chain a set of enumerations.
- [CollateMap<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/collatemap.md): (static) Collate all array elements that line up with true array in the map at the start of the array.
- [CollateNulls<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/collatenulls.md): (static) Collate all null elements in an array.
- [ContainsMetaData](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/containsmetadata.md): (2 overloads, static) Gets whether a collection of pears contains any meta data.
- [Convert<T, TQ>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/convert.md): (2 overloads, static) Convert an array of one type into another.
- [Copy<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/copy.md): (static) Copies specific elements from an array into another array.
- [CopyFirstItems<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/copyfirstitems.md): (static) Copy the first N items from one array to the start of another.
- [CopyLastItems<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/copylastitems.md): (static) Copy the last N items from one array to the end of another.
- [CountOrDefault<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/countordefault.md): (static) Guess the length of a collection. If the type cannot be quickly resolved, a default value is returned.
- [Create](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/create.md): (6 overloads, static) Create an array out of all non-NaN elements in a collection.
- [CreatePluralityMap<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/createpluralitymap.md): (2 overloads, static) Convert a collection of elements into a set with valence tracking.
- [Cull<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/cull.md): (static) Apply a culling pattern to an array.
- [Duplicate<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/duplicate.md): (3 overloads, static) Clone a jagged array.
- [EntrywiseEquals](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/entrywiseequals.md): (3 overloads, static) Compare two string arrays.
- [ExpandArray<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/expandarray.md): (2 overloads, static) Expand an array.
- [FindInclusion](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/findinclusion.md): (static) Find the index of the first interval which contains the given value.
- [FindLocalMaximum](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/findlocalmaximum.md): (6 overloads, static) Find the first local maximum in an array of doubles.
- [FindLocalMinimum](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/findlocalminimum.md): (6 overloads, static) Find the first local minimum in an array of doubles.
- [FindRange<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/findrange.md): (2 overloads, static) Find the first range that passes the predicate.
- [FirstIndexOf<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/firstindexof.md): (4 overloads, static) Return the first index within the array where a specific predicate returns true.
- [Flip<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/flip.md): (static) Flip a two-dimensional, rectangular nested array.
- [ForEachBackwards<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/foreachbackwards.md): (static) Enumerate over an array in a backwards fashion (from the highest to the lowest index).
- [ForEachForwards<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/foreachforwards.md): (static) Enumerate over an array in a forwards fashion (from the lowest to the highest index).
- [Format<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/format.md): (2 overloads, static) Format an array.
- [FromFunc<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/fromfunc.md): (static) Create and populate an array.
- [HorizontalIntersect](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/horizontalintersect.md): (static) Perform an inverse transform sampling on an array of increasing doubles. This means treat the array as a polyline and intersect it with a horizontal ray whose y-value is constant. If the array is not strictly increasing, the results of this method cannot be relied upon.
- [IndexOf](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/indexof.md): (static) Finds the first occurrence of an array within another array.
- [Inject<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/inject.md): (static) Inject an item into the array. All items starting at the index will be moved one position to the right. The last item will disappear. This method differs from Insert in that Inject does not change the array size, nor does it create a second, modified array.
- [Insert<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/insert.md): (2 overloads, static) Insert a collection of items into this array.
- [Invert](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/invert.md): (static) Invert a bool enumeration.
- [IsNullOrEmpty](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/isnullorempty.md): (2 overloads, static) Test an array for null-ness of empty-ness.
- [IsNullOrOnlyHasNulls<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/isnulloronlyhasnulls.md): (static) Gets whether the array instance is null, empty, or contains only null items.
- [Item<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/item.md): (2 overloads, static) Gets the item at a cyclical index.
- [Keep<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/keep.md): (static) Apply a culling pattern to an array.
- [Last<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/last.md): (static) Gets the last item in an array.
- [LastIndexOf<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/lastindexof.md): (2 overloads, static) Return the last index within the array where a specific value can be found.
- [Map](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/map.md): (2 overloads, static) Map an index specified within a expanded collection to the appropriate index in the unexpanded collection.
- [MetaDataCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/metadatacount.md): (static) Count the number of meta data entries. An entry with zero key-value fields does not count towards the total.
- [MostDerivedTypeConstraint<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/mostderivedtypeconstraint.md): (static) Gets the most derived type constraint required to store all the elements in the array.
- [Negate](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/negate.md): (static) Invert all array in a boolean array.
- [NoneNull<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/nonenull.md): (static) Tests whether none of the pears are null.
- [Normalise](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/normalise.md): (8 overloads, static) Normalise all values in an array so they sum to a specific value.
- [NullIfEmpty<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/nullifempty.md): (static) Returns a null reference if the array contains only null array. Otherwise returns the same array.
- [OrderedHash<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/orderedhash.md): (static) Compute the hash for an array of values, taking into account ordering. I.e. the hash for {0, 1, 2} will be different than the hash for {0, 2, 1}.
- [PadLeft<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/padleft.md): (static) Pad an array on the left side (before the first index) until it has a specific length. This method will not reduce the length of an array if it is already longer than the target length. If the array need not be modified the same instance is returned.
- [PadRight<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/padright.md): (static) Pad an array on the right side (after the last index) until it has a specific length. This method will not reduce the length of an array if it is already longer than the target length. If the array need not be modified the same instance is returned.
- [Pop<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/pop.md): (static) Remove the last item from an array.
- [PopFirst<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/popfirst.md): (static) Remove the first item from an array.
- [Process<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/process.md): (static) Apply a function to an enumeration.
- [Push<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/push.md): (2 overloads, static) Append a collection of items to the end of an array.
- [PushFirst<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/pushfirst.md): (static) Push an item into the first position of an array.
- [Random<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/random.md): (static) Gets a random item out of this array.
- [RemoveAll<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/removeall.md): (2 overloads, static) Remove specific items from an array.
- [RemoveAt<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/removeat.md): (static) Remove a specific element from an array.
- [RemoveDuplicates<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/removeduplicates.md): (3 overloads, static) Remove all duplicate array elements using a custom comparer.
- [RemoveRange<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/removerange.md): (static) Remove a range of items from an array.
- [ReorderByKey<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/reorderbykey.md): (static) Apply a minimal, stable reordering to an array based on an ordering constraint. Do note that this method replaces values in the array with values in the keys, so this should only be used when that swap doesn't matter.
- [ReplaceFirst<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/replacefirst.md): (static) Replace the first occurance of a value within an array with another one.
- [ReplaceLast<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/replacelast.md): (static) Replace the last occurance of a value within an array with another one.
- [ReplacePattern](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/replacepattern.md): (static) Replaces all occurrences of a Guid pattern within a source array with a single replacement Guid.
- [ReplaceWithinIntervals](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/replacewithinintervals.md): (static) Replace all array in an array of doubles that fall inside any of the domains with a different value. This method is significantly faster than checking each element against each domain, but it does require the array of doubles is already sorted.
- [Reverse<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/reverse.md): (static) Create a reversed copy of an array.
- [SameAccess](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/sameaccess.md): (static) Checks whether all access flags are of a single kind.
- [SetAll<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/setall.md): (2 overloads, static) Set a range of array of an array to a specific value.
- [SetFirstAndLast<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/setfirstandlast.md): (static) Set the first and last elements in an array simultaneously.
- [ShrinkArray<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/shrinkarray.md): (2 overloads, static) Shrink an array.
- [Slice<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/slice.md): (static) Slice the array between two indices. I.e. extract the sub-array limited by the indices.
- [SortAndMerge](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/sortandmerge.md): (static) Sort all intervals in an array from left to right and merge overlapping intervals.
- [SortMap<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/sortmap.md): (2 overloads, static) Sort an array and create a sorting map using a default comparer.
- [SortMapWithNulls<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/sortmapwithnulls.md): (static) Create a sorting map for an array with a null-mask array.
- [SortStable<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/sortstable.md): (static) Perform a count sort using integers as keys. CountSort (unlike QuickSort or IntrospectiveSort as used by the .NET framework) is stable, meaning the order of the input items is preserved in case of identical keys. It is however slower than QuickSort and doesn't like big or negative key array.
- [SortTopological<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/sorttopological.md): (2 overloads, static) Perform a topological sort on an array.
- [Stack<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/stack.md): (static) Stack up the elements until the array is filled up.
- [SumTotal<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/sumtotal.md): (3 overloads, static) Sum all elements in a collection.
- [Swap<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/swap.md): (static) Swap two items in an array.
- [ToByteArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tobytearray.md): (4 overloads, static) Convert a double[] into a byte[].
- [ToCoordinateArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tocoordinatearray.md): (4 overloads, static) Convert an array of SpatialVector array into an xyz coordinate array.
- [ToDoubleArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/todoublearray.md): (static) Convert a byte[] into a double[].
- [ToFloatArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tofloatarray.md): (static) Convert a byte[] into a float[].
- [ToHashByteArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tohashbytearray.md): (static) Create a byte array containing all the hashcodes of a collection of objects.
- [ToIntArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tointarray.md): (static) Convert a byte[] into an int[].
- [ToItemArray<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/toitemarray.md): (static) Create an item array from a pear array.
- [ToLongArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tolongarray.md): (static) Convert a byte[] into a long[].
- [ToMetaArray<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tometaarray.md): (static) Create a meta array from a pear array.
- [ToNullArray<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tonullarray.md): (static) Create a null array from a pear array.
- [ToPoint2dArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/topoint2darray.md): (static) Convert an array of sequential xy coordinates into a Point2d array.
- [ToPoint3dArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/topoint3darray.md): (static) Convert an array of sequential xyz coordinates into a Point3d array.
- [ToSpatialVectorArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tospatialvectorarray.md): (static) Convert an array of sequential xyz coordinates into a SpatialVector array.
- [ToTypeArray<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/totypearray.md): (static) Create a type array from a pear array.
- [ToVector3dArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/tovector3darray.md): (static) Convert an array of sequential xyz coordinates into a Vector3d array.
- [Trim<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/trim.md): (static) Resize an array to contain all items until a specific value.
- [UnorderedHash<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/unorderedhash.md): (static) Compute the hash for an array of array, not taking into account ordering. I.e. the hash for {0, 1, 2} will be the same as the hash for {0, 2, 1}.
- [Withdraw<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/withdraw.md): (static) Withdraw an item from the array. All items to the right of the index will be moved one position to the left. This method differs from RemoveAt in that Withdraw does not change the array size, nor does it create a second, modified array.
- [Wrap<T, TQ>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.extensions.arrayex/wrap.md): (static) Wrap an IEnumerable into another IEbumerable of a different type.
