0

I am trying to create a empty 3D array in PowerShell. I saw some examples online and I have used this line to create it.

 $mulArr = @(@(),@(),@())

And I have added some values to this using the line below

 $mulArr+= ('a',@('b','c'),'v')

When I checked the length of the array above using $mulArray.Length, it is showing as desired. But I am unable to access the array elements explicitly like below.

$mulArr[0,0,1]

This is not returning any value. Please help me understand where I am going wrong with this.

karun_r
  • 183
  • 1
  • 2
  • 14
  • 1
    what return value do you expect? – Martin Brandl May 07 '16 at 18:45
  • 4
    You have jagged array not multidimensional array. – user4003407 May 07 '16 at 19:03
  • 1
    Note that the relevant answer in the linked duplicate is not the accepted answer for the question (it applies better here than it did there). – briantist May 07 '16 at 19:51
  • @briantist I've seen that question before posting this one. But there he is explicitly mentioning the size of the multidimensional array. I don't want to do that here. I just want to see a matrix kind of output with the values I provide. – karun_r May 08 '16 at 03:32
  • @karun10 if you want a dynamically sized array, the jagged array is the way to go. Also, what would a 3D matrix look like on a 2D screen? :-) – Mathias R. Jessen May 08 '16 at 10:24
  • @MathiasR.Jessen I meant 3x3 kind of thing. I see what I did there.. My bad :) So for a dynamically sized multidimensional array, jagged array is the only way to go ? – karun_r May 08 '16 at 17:29

0 Answers0