mercredi 1 juillet 2015

How to ask say "or" in an if-statment

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";
            }
        }

In each statement there are 3 values that it could equal to display the correct number. but I dont want to write like 15 if/else statments to make it work. I tried using "||", "|", "&", and "&&" (without the quotes of course). But I keep getting an error that says "Operator cannot be applied to operands of type 'bool' and 'string'

Aucun commentaire:

Enregistrer un commentaire