How do I convert an array object to a string in PowerShell?

前端 未结 6 1659
执念已碎
执念已碎 2020-12-07 08:45

How can I convert an array object to string?

I tried:

$a = \"This\", \"Is\", \"a\", \"cat\"
[system.String]::J         


        
6条回答
  •  孤街浪徒
    2020-12-07 09:05

    1> $a = "This", "Is", "a", "cat"
    
    2> [system.String]::Join(" ", $a)
    

    Line two performs the operation and outputs to host, but does not modify $a:

    3> $a = [system.String]::Join(" ", $a)
    
    4> $a
    
    This Is a cat
    
    5> $a.Count
    
    1
    

提交回复
热议问题