I am trying to read a set of data and place it in an array "cell by cell". in my head the array should look like this:
[0,0][0,1][0,2]
[1,0][1,1][1,2]
[2,0][2,1][2,2]
[3,0][3,1][3,2]
[4,0][4,1][4,2]
I'm pretty sure its a Jagged array I am after, I want to be able to assign a value to each cell individually, in my testing I can assign values row by row no problem. but that doesn't help me.
My basic code looks like this:
$Array = @()
for ($row=0; $row=4; $row++){
for ($column=0; $column=2; $column++){
$Array[$row][$column] += @("Row: $row, Column: $column")
}
}
It should just go through cell by cell putting some information in each cell
I've had a look through the usual suspects which are referenced on Powershell Array questions here;
- www.leedesmond.com/weblog/?p=183
- 4sysops.com/archives/arrays-in-powershell-create-change-read-sort-delete/
- en.wikiversity.org/wiki/Windows_PowerShell/Arrays_and_Hash_Tables#Adding_Elements_to_an_Array
Thanks in advance
EDIT: Even if i use the examples in that and modify my code to
$Array = New-Object 'object[,]' 3,3
my output is just a list:
Row: 0, Column: 0
Row: 0, Column: 1
Row: 1, Column: 0
Row: 1, Column: 1
I was expecting a table layout