1
我想我的布爾值轉換在PowerShell中的以下內容:轉換布爾值到字符串
- 真→ GREEN
- 假→ RED
這裏是我的這個相關代碼
$SecMasSQLRes | ForEach-Object {
if ($SecMasSQLRes.CusipPercent -lt 25) {
Write-Host CusipStatus = GREEN
} else {
Write-Host CusipStatus = RED
}
if ($SecMasSQLRes.ISINPercent -lt 10) {
Write-Host IsinStatus = GREEN
} else {
Write-Host IsinStatus = RED
}
if ($SecMasSQLRes.SymbolPercent -lt 10) {
Write-Host SymbolStatus = GREEN
} else {
Write-Host SymbolStatus = RED
}
}
$CusipResults = $SecMasSQLRes.CusipPercent -lt 25
$IsinResults = $SecMasSQLRes.ISINPercent -lt 10
$SymbolResults = $SecMasSQLRes.SymbolPercent -lt 10
$CusipResults
$IsinResults
$SymbolResults
'$變量=如果(條件){'綠色 '}否則{' 紅 '}' – PetSerAl
'$查找= @ {$假=' 紅 '; $真='綠色'}; $ lookup [$ MyBool]' – TessellatingHeckler
Golf'd:'@('RED','GREEN')[$ bool]' –