Powershell Joins Powershell Joins powershell powershell

Powershell Joins


Wrap the content of "$a[0,1,2,3]" with "$()" or "()"

PS> [string]::join("", $($a[0,1,2,3]))hellPS> [string]::join("", ($a[0,1,2,3]))hell

-- Or --

you can use range operator ".."

PS> [string]::join("", $a[0..3])hell


PS > & {$ofs=""; "$($a[0,1,2,3])"}  hell


More idiomatic: use PowerShell's built-in join operator like this:

PS> $a[0,1,2,3] -join ""hell