小编Jus*_*saj的帖子

如何在if语句中说"或"

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语句来使它工作.我尝试使用||,|,& …

c# if-statement visual-studio-2012

1
推荐指数
1
解决办法
756
查看次数

标签 统计

c# ×1

if-statement ×1

visual-studio-2012 ×1