2016-05-20 41 views
-1

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

$DistributionPointGroups = @("London") 

回答

1

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

阵列子表达式OPERATOR

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

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