private void caseTextBox_TextChanged(object sender, EventArgs e)
{
var CTcase = caseTextBox.Text;
caseTextBox.CharacterCasing = CharacterCasing.Upper;
if (CTcase == "THRUHOLE")
{
displayLabel3.Text = "0";
}
else if (CTcase == "EIAA")
{
displayLabel3.Text = "1";
}
else if (CTcase == "EIAB")
{
displayLabel3.Text = "2";
}
else if (CTcase == "EIAC")
{
displayLabel3.Text = "3";
}
else if (CTcase == "EIAD")
{
displayLabel3.Text = "4";
}
else
{
displayLabel3.Text = "error";
}
}
Run Code Online (Sandbox Code Playgroud)
在每个语句中,有3个值可以等于显示正确的数字.但我不想写15 if/ else语句来使它工作.我尝试使用||,|,& …