C#C
C#2y ago
MaxHayman

Inline array of struct assignment

Hey,

I am trying to implement something using inline arrays, however I am struggling to get a way to do it in a clean way.
    [System.Runtime.CompilerServices.InlineArray(10)]
    public struct Buffer10<T>
    {
        private T _element0;
    }

 public Buffer10<Header> Headers { get; set; }

    public void AddHeader(Header header)
    {
        Headers[HeadersCount++] = header;
    }


gets

Error CS0131 : The left-hand side of an assignment must be a variable, property or indexer


I am sure this worked in preview .net 8.

Does anyone have any experience using inline arrays yet. It feels rough having to have some kind of proxy struct and i wish you could do this on the field/property level.
Was this page helpful?