Multiple condition C#

Asked

Viewed 33 times

2

I’m trying to validate if a user is a teacher and if they type "s" or "n" uppercase or lowercase but this getting caught in the loop with the condition being true or false.

while ((array [i, 1] != "S") || (array [i, 1] != "s") || (array [i, 1] != "n") || (array [i, 1] != "N"))

  • Hello Paul, it is important [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem. To better enjoy the site, understand and avoid closures is worth reading the Stack Overflow Survival Guide in English. Thank you for understanding.

1 answer

2


Paul, try to change the operator Or (||) to And (&&). As you are comparing the same element with more than one value, it will surely always be different from at least one of them.

I hope it helps

Browser other questions tagged

You are not signed in. Login or sign up in order to post.