我所要做的就是看用戶輸入$ month是否在數組$ month中。但它不喜歡什麼。幫幫我?- 包含運算符不工作powershell
Write-host "The script is to collect from the user High Tempature and Low Tempature for a day in degrees F."
$months = @("January", "February","March","April","May","June","July","August","September","October","November","December")
$finished = $false
while ($finished -eq $false){
$month = read-host "Enter the month";
if ($months -Contains $month)
{
write-host "Invalid entry"
$finished = $false
}
else
{
$finished = $true
}
}
那麼,這是工作,測試不是好的? – JPBlanc 2015-04-01 03:25:16
@JPBlanc它的工作原理是,如果他做得對,是的,但是他不會遇到大小寫敏感問題?或者 - 是否包含大小寫不敏感? – TheMadTechnician 2015-04-01 03:41:27
'CContains'區分大小寫,而不是'Contains'。 – JPBlanc 2015-04-01 03:44:50