public readonly struct TestStruct
{
public static TestStruct New()
=> new() { _array = new float[SomeEnumLenght] };
private readonly float[] _array;
public readonly float this[SomeEnum key] // IMO adding "readonly" to instance members when the hole struct is readonly is a bit silly, but just adding it here incase that makes a difference?
{
get => _array[(int)key];
set => _array[(int)key] = value;
}
}
static class Program
{
static void Main()
{
var test = new TestStruct();
_=test[0];
}
}
public readonly struct TestStruct
{
public static TestStruct New()
=> new() { _array = new float[SomeEnumLenght] };
private readonly float[] _array;
public readonly float this[SomeEnum key] // IMO adding "readonly" to instance members when the hole struct is readonly is a bit silly, but just adding it here incase that makes a difference?
{
get => _array[(int)key];
set => _array[(int)key] = value;
}
}
static class Program
{
static void Main()
{
var test = new TestStruct();
_=test[0];
}
}