Answer the question
In order to leave comments, you need to log in
C# - How to set multiple values to one "if"?
Hello! I am learning to write in C#. I got a little problem. My situation: For example:
if (A == "Yes")
{
text
}
else if (A == "Yeah")
{
text
}
else if (A == "Uh-huh")
{
text
}
and so on
And this text everywhere the same. Question: Is it possible to immediately write "if A = "yeah", "uh-huh" and so on (something like that) and this very text"
I hope I explained the problem correctly. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Read about logical operations
Here you need to use "OR" - ||
if a == "yeah" || a == "yup" {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question