DouglasDwyer.FixedArray 0.1.1

dotnet add package DouglasDwyer.FixedArray --version 0.1.1
                    
NuGet\Install-Package DouglasDwyer.FixedArray -Version 0.1.1
                    
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="DouglasDwyer.FixedArray" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DouglasDwyer.FixedArray" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="DouglasDwyer.FixedArray" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DouglasDwyer.FixedArray --version 0.1.1
                    
#r "nuget: DouglasDwyer.FixedArray, 0.1.1"
                    
#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.
#:package DouglasDwyer.FixedArray@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DouglasDwyer.FixedArray&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=DouglasDwyer.FixedArray&version=0.1.1
                    
Install as a Cake Tool

Nuget Downloads

DouglasDwyer.FixedArray

Rust-style fixed-size stack-allocated arrays for C#. Provides Array1<T> through Array32<T> — value types backed by [InlineArray] that live entirely on the stack with no heap allocation.

Installation

dotnet add package DouglasDwyer.FixedArray

The package bundles a Roslyn source generator that emits Array1<T>Array32<T> into your project at compile time. No runtime dependency is needed beyond the small support types (IFixedArray<T>, FixedArrayEnumerator<T, A>) included in the package.

Usage

Construction

Use C# collection expressions (requires C# 12+):

Array3<int> rgb = [255, 128, 0];

Or use the explicit constructor:

var point = new Array2<float>(1.0f, 2.5f);

Indexing

Each type is an [InlineArray] struct, so standard index syntax works:

Array3<int> v = [10, 20, 30];
int x = v[0];
v[1] = 99;

Enumeration

All array types implement IEnumerable<T>, so foreach and LINQ work out of the box:

Array4<string> words = ["hello", "fixed", "stack", "array"];

foreach (var w in words)
    Console.WriteLine(w);

var upper = words.Select(w => w.ToUpper()).ToList();

Equality

Arrays support ==, !=, Equals, and GetHashCode, all compared element-by-element:

Array2<int> a = [1, 2];
Array2<int> b = [1, 2];
Console.WriteLine(a == b); // True

API

Type Description
Array1<T>Array32<T> Stack-allocated fixed-size array structs.
IFixedArray<T> Interface exposing Length and Get(int i), useful for generic constraints.
FixedArrayEnumerator<T, A> Struct enumerator returned by GetEnumerator() — no boxing.

Requirements

  • .NET 8.0 or later
  • C# 12 or later (for collection expression syntax)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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.

Version Downloads Last Updated
0.1.1 131 6/19/2026
0.1.0 93 6/19/2026