How to declare an 3-dimensional array in C#?
I just tried to create an 3-dimensional array in C# (which seems to work, at least there are no errors)
private int[,,] myarray = new int [sizeX,sizeY,sizeZ];
but when I try to write to the array
myarray [valueX,valueY,valueZ] = 1;
I get the following error:
error CS0266: Cannot implicitly convert type `float' to `int'. An explicit conversion exists (are you missing a cast?)
How do I use multidimensional arrays correctly?
Thanks in advance
Greets, xLuboex
Answer by Rostam24 · Sep 26, 2015 at 08:19 PM
sounds like the values you are putting in the array are floats, so you would need to do this: flloat[,,] myarray = new float[sizeX, sizeY, sizeZ];
Any chance valueX, valueY and valueZ are floats?
They actually are myVector.x, myVector.y and myVector.z. I don't know if Unity treads the values of a vector as floats...
Your answer
Follow this Question
Related Questions
How to make a number higher than Quintillion? (1000000000000000000) 1 Answer
Convert "Double" to "Float" or "Int"? 1 Answer
Int returns 0 after value is assigned, ,Int returns 0 within certain method, Can't figure out why. 0 Answers
Error BCE0051 with script JS 1 Answer
How to move an object's own Y position relative to a slider's Y position? 1 Answer