是的,這是另一個PowerShell的回報問題...PowerShell的返回與string.replace值
$str = 'My {token} string'
$newStr = $str.Replace('{token}', 'value')
$newStr
My value string
function strReplace ($str, $rval) { $str.Replace('{token}', $rval) }
$newStr = strReplace($str, 'value')
$newStr
My string
value
即使返回與string.replace一個字符串,對象[]在返回管道出現。爲什麼??有沒有辦法獲得明顯的回報價值?
當我運行這段代碼,它獲得與以下行錯誤: $中newstr = strReplace($海峽,「值') 但我用它替換它時: $ newStr = strReplace $ str'value' 它按預期工作。我使用的是.net 4.0的Powershell 2.0 – 2013-02-21 20:05:42
也許這是對ps3的改變? – bob 2013-02-21 20:35:51