Powershell 在此处字符串函数中展开时,变量出现错误
我刚刚遇到了一个我认为很奇怪的问题,但很可能我只是做错了什么 当我运行此代码时:Powershell 在此处字符串函数中展开时,变量出现错误,powershell,Powershell,我刚刚遇到了一个我认为很奇怪的问题,但很可能我只是做错了什么 当我运行此代码时: Function OutOfOrder($animal,$verb,$adjective) { @" The quick brown $animal $verb over the $adjective dog "@ } OutOfOrder("fox","jumped","lazy") 这是我收到的输出: The quick brown fox jumped lazy over the dog PS2.0
Function OutOfOrder($animal,$verb,$adjective) {
@"
The quick brown $animal $verb over the $adjective dog
"@
}
OutOfOrder("fox","jumped","lazy")
这是我收到的输出:
The quick brown fox jumped lazy over the dog
PS2.0和3.0中的行为相同。有什么好处
谢谢 这是一个常见的错误。调用powershell函数时不应使用paren和逗号 您向第一个参数传递了一个由3个字符串组成的数组,而另2个字符串为空 试试这个:
OutOfOrder "fox" "jumped" "lazy"