title: Powershell: Multidimensional array as return value of function
body: <p>I've got some problems with two-dimensional arrays in PowerShell. 
  Here's what I want to do: </p>
  
  <p>I create a function that is supposed to return a two-dimensional array. When invoking the function I want the return value to be a new two-dimensional array. </p>
  
  <p>For a better understanding I've added an example function, below:</p>
  
  <pre><code>function fillArray() {
      $array = New-Object 'object[,]' 2,3
  
      $array[0,0] = 1
      $array[0,1] = 2
      $array[0,2] = 3
  
      $array[1,0] = 4
      $array[1,1] = 5
      $array[1,2] = 6
  
      return $array
  }
  $erg_array = New-Object 'object[,]' 2,3
  $erg_array = fillArray
  
  $erg_array[0,1] # result is 1 2
  $erg_array[0,2] # result is 1 3
  $erg_array[1,0] # result is 2 1
  </code></pre>
  
  <p>The results are not what I expect. I want to return the information in the same way as declared in the function. So I would expect <code>$erg_array[0,1]</code> to give me <code>2</code> instead of the <code>1,2</code> I receive with the code above. How can I achieve this?</p>