T
T
Tony13372017-03-24 23:54:51
Programming
Tony1337, 2017-03-24 23:54:51

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

1 answer(s)
R
RedHairOnMyHead, 2017-03-24
@Tony1337

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 question

Ask a Question

731 491 924 answers to any question