jeudi 26 octobre 2017

how to use switch case like (if)?

I want to use switch like if in my code but I dont know how to use && in case ! this is my code

string a;
a = System.Convert.ToString(textBox1.Text);

if (a.Contains('h') && a.Contains('s'))
{
    this.BackColor=Color.Red;
}
else if (a.Contains('r') && a.Contains('z')) 
{
    this.BackColor=Color.Black;

}

else if (a.Contains('a') && a.Contains('b'))
{
    this.BackColor = Color.Pink;

}

Aucun commentaire:

Enregistrer un commentaire