在powershell中使用@

时间:2016-05-20 06:51:32

标签: powershell

我经常在Powershell编码中看到@符号的用法。想问一下它用于什么?示例如下

$DistributionPointGroups = @("London")

1 个答案:

答案 0 :(得分:1)

@()是数组运算符,它确保即使单个项(或零)作为数组返回。

  

阵列子表达式操作员

     

数组子表达式运算符创建一个数组,即使它也是如此       包含零个或一个对象。

The syntax of the array operator is as follows:
    @( ... )

You can use the array operator to create an array of zero or 
one object. 

    PS C:\>$a = @("One")
    PS C:\>$a.Count
    1

    PS C:\>$b = @()
    PS C:\>$b.Count
    0

来源:about_Arrays