PowerShell: Nested Array, Multi-Dimensional Array
Nested Array
🛑 WARNING: Nested Array is different from multi-dimensional array. dotnet has dedicated type for multi-dimensional array, typically used as a matrix.
# a nested array $x = @( @(1,2), @(3,4), @(5,6) ) $x.length # 3 $x[0][0] # 1 $x[0][1] # 2
Multi-Dimension Array
- Use
rank
to get the dimension of a multi-dimension array. - Use
arr[i,j]
to get a element in a multi-dimension array.
# create a multi-dimensional array [int32[,]] $x = [int32[,]]::new(3,2) $x.length # 3 $x.rank # 2 # means is a 2d matrix Write-Host $x # 0 0 0 0 0 0 # by default, all values are 0 $x[0,0] = 1 Write-Host $x # 1 0 0 0 0 0
PowerShell: Array
- PowerShell: Array
- PowerShell: Array Sub-Expression Operator @(), Collection to Array
- PowerShell: Array and Types
- PowerShell: Nested Array, Multi-Dimensional Array
- PowerShell: Array, Get Item
- PowerShell: Array, Set Item
- PowerShell: Test If Collection Contains a Value
- PowerShell: Join Array, Append
- PowerShell: Filter Array
- PowerShell: Delete Array, Clear Array
- PowerShell: Array to String
- PowerShell: Array Methods
- PowerShell: Iterate Array