2016-05-20 38 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