ArrayExtensions 1.2.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ArrayExtensions --version 1.2.0
NuGet\Install-Package ArrayExtensions -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ArrayExtensions" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ArrayExtensions --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ArrayExtensions, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ArrayExtensions as a Cake Addin
#addin nuget:?package=ArrayExtensions&version=1.2.0
// Install ArrayExtensions as a Cake Tool
#tool nuget:?package=ArrayExtensions&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ArrayExtensions
A collection of useful extension methods for arrays in C#.
Features
- Basic Operations: Easily
Add
,Insert
,Remove
, andReplace
items. - Array Manipulation:
Shuffle
,Rotate
,Chunk
,Flatten
, andResize
your arrays. - Array Analysis: Check if arrays are
AllEqual
,AnyNull
,IsEmpty
, or even find theMostCommon
element. - String Array Utilities: Methods like
TrimAll
,AnyNullOrEmpty
, andConcatenateWithSeparator
. - DateTime Array Utilities: Filter by
Weekdays
,Weekends
,Holidays
, and more. - Safe Operations: Safely
Get
,Set
, andFindIndices
without worrying about out-of-range errors. - Functional Programming: Use
ForEach
to apply actions directly on array elements. - ... and many more
Installation
Install via NuGet:
Install-Package ArrayExtensions
Or just copy whatever you need from this repository 😃
Usage
Some examples:
using ArrayExtensions;
// Basic array of fruits
string[] fruits = { "apple", "banana", "cherry" };
// Add items
fruits = fruits.Add("date").AddRange("fig", "grape");
// Manipulate array
fruits = fruits.InsertAt(2, "blueberry").RemoveAt(3).Shuffle();
// Analyze array
bool allSame = fruits.AllEqual();
bool hasEmptyOrNull = fruits.AnyNullOrEmpty();
// String utilities
string[] trimmedFruits = { " apple ", "banana ", " cherry", " date " };
trimmedFruits = trimmedFruits.TrimAll();
// DateTime utilities
DateTime[] holidays = { new DateTime(2023, 12, 25), new DateTime(2023, 1, 1) };
var holidayDates = dates.FilterHolidays(holidays);
var weekdays = dates.FilterWeekdays();
// Safe operations
var fruit = fruits.SafeGet(10, "unknown");
var indices = fruits.FindIndices(f => f.StartsWith("a"));
// Functional programming
fruits.ForEach(Console.WriteLine);
// More advanced operations
var chunkedFruits = fruits.Chunk(2); // Splits the array into chunks of 2
var rotatedFruits = fruits.RotateLeft(2); // Rotates the array to the left by 2 positions
var lastThreeFruits = fruits.LastN(3); // Retrieves the last 3 fruits
var distinctFruits = fruits.DistinctValues(); // Gets distinct fruit values
var mostCommonFruit = fruits.MostCommon(); // Finds the most common fruit
// DateTime specific operations
DateTime[] dateArray = { new DateTime(2023, 1, 1), new DateTime(2023, 2, 14), new DateTime(2023, 12, 25) };
var range = dateArray.DateRange(); // Gets the range between the earliest and latest date
var closestToNewYear = dateArray.ClosestTo(new DateTime(2023, 1, 15)); // Finds the date closest to Jan 15, 2023
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.