PowerShell: Join Array, Append
🛑 WARNING: Array type is fixed size data structure. when you add item, PowerShell creates a new array. The more items in a array, the slower it is to create a new array.
Append an Item
Use operator +=
to add a item to end of array.
$x = @(1, 2, 3) # add a item "b" to the end $x += "b" Write-Host $x # 1 2 3 b
Join Arrays
use +
operator.
$a = @(1,2) $b = @(3,4,5) $c = $a+$b Write-Host $c # 1 2 3 4 5
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 (Where-Object)
- PowerShell: Delete Array, Clear Array
- PowerShell: Array to String
- PowerShell: Array Methods
- PowerShell: Iterate Array