I have a 2D Array uint[][100] myArray. I want to access the length of the first dimension (the dynamic array). Therefore I use myArray.length, but then I get the value 100 the length of the second dimension (the static array).

How can I get the the length of the first dimension?

  • myArray[0].length obviously Jun 20, 2020 at 8:16
  • And of course, there is no such thing "the length of the first dimension" here, since each one of your 100 sub-arrays may have a different length. Jun 20, 2020 at 8:23
  • At myArray[0].length I would expect 100
    – wero026
    Jun 20, 2020 at 8:56
  • Does Solidity specifiy multi dimensional arrays in reverse order than other programming languages do, like C or Java? Normally I would expect that myArray.length gives the length of the dynamic part and myArray[0].length of the static part, that is 100.
    – wero026
    Jun 20, 2020 at 9:01
  • No, 100 is myArray.length. At myArray[0].length you should expcet however many elements you've pushed there. Jun 20, 2020 at 9:17

1 Answer 1


After reading the docs (which should be done before posting here ;) ) I found out that the specification of multi dimensional arrays in Solidity are in reverse order than it is in other programming languages, like C or Java.

So uint[][100] myArray would be 100 arrays of dynamic sized uint arrays. And myArray.length would be of course 100.

But what I actually want was uint[100][] myArray. A dynamic array within of each an array of 100 uints. Then myArray.length gives me the size of the dynamic array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.