Exploring Inline Arrays
01/06/2024
Inline arrays have been introduced as new feature in C# 12. As the feature is preview at the time of writing, it may change before the .NET team releases the final version of C#.
A type attributed with inline array can be used to represent a fixed-size, contiguous sequence of primitives. The runtime and language provide type and overrun safe indexing operations to the underlying primitives.
At the time of writing one can define an inline array by applying the [InlineArray]
attribute on a struct, that has a single field.
[System.Runtime.CompilerServices.InlineArray(8)] struct Octet { private int _element0; }