Static readonly Arrays Island c#

These compiles fine in Echoes but not Island.
How should it be replaced?

 private  static readonly double[,] UnitFactors =
        {
            {
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            },
            {
                1, 1, 0.0833333333333333, 1.57828282828283E-05, 25.4, 2.54, 0.0254, 2.54E-05, 1000000, 1000, 0.0277777777777778, 254000000, 25400000, 25400, 0.254, 0.00254, 0.000254, 2.54E-11, 1.697885129158E-13, 8.231579395684E-19
            }
         }

Message : not supported on this platform…

I think it works if you were to define the bounds. ie double[2, 15]. We don’t support dynamic multidim arrays on Island/Toffee.

maybe I’m stupid somewhere but : it won’t work like these

 private  static readonly double[2,2] UnitFactors =
        {
            {
                1, 1
            },
            {
                1, 1
               
            }
        }

` E: One of “this”, identifier, “operator” expected, got opening square bracket

Thanks, logged as bugs://81401

hrmm oke I’ll take a look.

Any news about this?

not yet. Finding a good syntax for this is tricky.

Sorry I don’t understand…
It is valid C#? I can understand the dynamic problem, can be solved because
of the immutable but the rest?

Island (and toffee) don’t support dynamic multidim arrays. It does support constantly sized multidim arrays but only in Oxygene because there’s no equivalent for:
array [0..2, 0..15] of Byte;

thats where the problem lies. We currently don’t have plans for supporting dynamic multidim arrays (ones which dims are determined at runtime) on Toffee, Island or Cooper.

My problem is not the dynamic.

How can I uses something like this in Island and Silver?

 public  static readonly double[2,2] UnitFactors =
{
            {
                1, 1
            },
            {
                1, 1
               
            }
        }

Sorry for a p… in the a…
i have tried to change the *.cs to *.pas…
You can see in the zip what oxigene has done so far.
Units.zip (5.1 KB)

yes. I’m looking into a solution for this problem, to make constants like that work.

You can use this:

double[][]

instead (works on all targets)

will this work for you?

Yes this will work for me,
thanks

1 Like