SkillAgentSearch skills...

ArrayExtensions

Comprehensive collection of 245 extension methods for C# arrays. Also available as NuGet package.

Install / Use

/learn @Tim-Maes/ArrayExtensions
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ArrayExtensions

A comprehensive collection of extension methods for arrays in C#.

Index

Installation :wrench:

Install via NuGet:

Install-Package ArrayExtensions

Or just copy whatever you need from this repository :)

Usage

var result = array.MethodName();

Features :star:

Generic Array methods

| Name | Description | |---------------------------------------------------|---------------------------------------------------------------------------| | Add<T>(), AddRange<T>() | Appends single or multiple items to the end of an array. | | AllEqual<T>() | Checks if all elements in an array are identical. | | AnyNull<T>() | Determines if any element in an array of reference types is null. | | BinarySearch<T>() | Performs a binary search on a sorted array. | | Chunk<T>() | Divides an array into smaller arrays of a specified maximum size. | | Contains<T>() | Checks if the array contains a specified element. | | CountOf<T>() | Counts occurrences of a specific item in the array. | | DeepCopy<T>() | Creates a deep copy of an array, where elements implement ICloneable. | | DistinctBy<T, TKey>() | Returns distinct elements based on a specified selector function. | | DistinctValues<T>() | Returns distinct values from the array. | | FindFirstAndLast<T>() | Finds the first and last elements that match a given predicate. | | FindIndices<T>() | Finds indices of all elements that match a given predicate. | | FindOrDefault<T>() | Finds an element matching a predicate, or returns a default value. | | Flatten<T>() | Flattens a multi-dimensional array into a single-dimensional array. | | ForEach<T>() | Executes an action on each element of an array. | | ForEachIndexed<T>() | Executes an action on each element of an array with its index. | | GroupBySequential<T, TKey>() | Groups adjacent elements sharing a key or property. | | Head<T>(), Tail<T>(), LastN<T>(), FirstN<T>() | Provide various ways to slice and access elements. | | Interleave<T>() | Interleaves elements of two arrays into a single array. | | InsertAt<T>() | Inserts an element at a specified index. | | IsNullOrEmpty<T>(), IsEmpty<T>() | Check if an array is empty or null/empty, respectively. | | IsSorted<T>() | Checks if the array is sorted according to a specified comparer. | | IsUnique<T>() | Determines whether all elements in the array are unique. | | JoinToString<T>() | Concatenates string representations of elements with a delimiter. | | Map<T, TResult>() | Transforms each element of the array using a selector function. | | MaxBy<T, TKey>(), MinBy<T, TKey>() | Finds the maximum/minimum element based on a specified selector function. | | MostCommon<T>() | Finds the most common element in the array. | | Permute<T>() | Generates all possible permutations of the array. | | RandomSample<T>() | Selects a random sample of elements. | | RemoveAt<T>() | Removes the element at a specified index. | | RemoveDuplicates<T>() | Removes duplicate elements from the array. | | RemoveNulls<T>() | Removes all null items from an array of reference types. | | ReplaceAll<T>() | Replaces all occurrences of a specific value with another in the array. | | Resize<T>() | Resizes an array to a specified new size. | | Reverse<T>() | Reverses the elements of the array. | | RotateLeft<T>(), RotateRight<T>() | Rotates the array left or right by a specified number of positions. | | SafeGet<T>() | Retrieves an element at a specified index or a default value if out of range. | | SafeSet<T>() | Sets a value at a specified index, resizing the array if necessary. | | Segment<T>() | Splits an array into segments based on a predicate. | | SequentialPairs<T>() | Generates a sequence of tuples from sequential pairs of elements. | | Shuffle<T>() | Randomly shuffles the elements of an array. | | Slice<T>() | Returns a portion of the array, similar to substring for strings. | | Subset<T>() | Returns all possible subsets of the array. | | SumBy<T>() | Calculates the sum of array elements based on a selector function. | | TakeWhile<T>(), SkipWhile<T>() | Takes or skips elements of the array while a condition is true. | | ToHashSet<T>() | Converts the array to a HashSet, removing duplicates. | | ZipWith<T, TOther, TResult>() | Combines two arrays into one using a specified selector function. |

DateTime Array methods

|Name | Description | |-----------------------------------|---------------------------------------------------| |AllInFuture| Checks if all dates in the array are in the future.| |AllInPast| Checks if all dates in the array are in the past.| |AverageTimeBetweenDates| Calculates the average time span between consecutive dates (when sorted).| |BusinessDaysCount| Calculates the number of business days between the earliest and latest date in the array.| |CalculateAges| Calculates ages (in years) for all dates relative to a reference date.| |ClosestTo| Gets the closest date to a specified reference date.| |DateRange| Gets the range between the earliest and latest date.| |EarliestDate| Finds and returns the earliest date present in the array.| |EquidistantDates| Finds dates that are equidistant from a given reference date.| |FilterByDateRange| Filters dates that fall within a specified date range.| |FilterByDecade| Filters dates that fall within a specific decade.| |FilterByQuarter| Filters dates that fall within a specific quarter of any year.| |FilterBySeason| Filters dates that fall within a specific season in the Northern Hemisphere.| |FilterHolidays| Filters dates that match a provided list of holidays.| |FilterLastDayOfWeek| Filters dates that fall on the last specific day of the week of their month.| |FilterNthDayOfWeek| Filters dates that are the nth occurrence of a specified day of the week in their month.| |FilterWeekdays| Filters dates that are weekdays (Monday to Friday).| |FilterWeekends| Filters dates that are weekends (Saturday or Sunday).| |FindBirthdays| Finds dates that are birthdays (same month and day) for a given reference date.| |FindMaximumGap| Finds the dates with the maximum gap between consecutive dates.| |GroupByDay| Groups dates by day.| |GroupByDayOfWeek| Groups dates by their day of the week.| |GroupByMonth| Groups dates by month.| |GroupByQuarter| Groups dates by quarter of the year.| |GroupByTimePeriod| Groups dates by time of day periods.| |GroupByYear| Groups dates by year.| |LatestDate| Finds and returns the latest date present in the array.| |RoundTo| Rounds all dates to the nearest specified time unit.| |SortChronologically| Sorts the dates in chronological order (earliest to latest).| |SortReverseChronologically| Sorts the dates in reverse chronological order (latest to earliest).| |ToLocalTime| Converts all dates to local timezone.| |ToUtc| Converts all dates to UTC timezone.|

String Array methods

|Name

Related Skills

View on GitHub
GitHub Stars23
CategoryDevelopment
Updated5mo ago
Forks2

Languages

C#

Security Score

87/100

Audited on Oct 27, 2025

No findings