Hi,
I’m using a 3d array on a C# component in Rhino6 (Windows) and every time I open the C# editor the code checker removes the comas inside the square brackets of the arrays declarations.
double[ , , ] xD = new double[ , , ]{{{1,2,3}}};
turns to
double[ , , ] xD = new double[]{{{1,2,3}}};
I’m not sure if this is a bug or if it is on purpose or but it is pretty annoying behavior.
The C# editor doesn’t support modern language syntax, maybe that’s why. Anyway, try doing it this way instead:
double[][][] xD = new double[][][];
But in that case I think you have to specify the size of the first dimension and in a loop instantiate the other dimensions, and not sure if you can use initializators with {}
.
Thanks @Dani_Abalde. I think I will try to use Tuples instead.
Tuple<string, double, double, double>[] tfEvent = {Tuple.Create(s, x, y1, y2)};
and change this
List<KeyValuePair<string, double[,,]>> xA = new List<KeyValuePair<string, double[,,]>>();
to
List<Tuple<string, double, double, double>[]> xA = new List<Tuple<string, double, double, double>[]>()
The values will not be changed after being created and I can mix types which I’ll simplify other parts of the code.
You can make it more elegant if you create a class with the properties you need and store them in a simple list.
Yes, you are right. Just don’t want to bother with that for now.
Thanks! I’m aware of that syntax I was just curious as to why the syntax I was using (which is also correct and is on Microsoft examples) was always being corrected by the script component.
Well … the build in editor is … er … crap (more or less). But as Dani said a class is a way better approach most notably if you want to query things…