-4

For example, in python an if statement can be made like this: if example3 == 1 or example 4 == 1: print("Test")

Is there anything equivalent in c#?

  • 1
    This question is not about `if` statements but about Boolean operators, which is something that any beginners tutorial would have shown you how to use. – John Aug 12 '22 at 03:00
  • I'd be surprised if there are many (if any) real programming languages that don't have such a construct for conditional statements. Simply searching "conditional statements" against the C# docs site produces the [Selection statements](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/selection-statements) documentation. – ProgrammingLlama Aug 12 '22 at 03:01
  • @John I have not watched any tutorials, I'm just making a project and learning as I do. – whyIsUsermanTaken Aug 12 '22 at 03:04
  • 1
    Then that's your problem. The purpose of this site is not to teach you the basics. It's for the hard stuff that you cannot work out for yourself. You need to do what you can for yourself first and learning what operators the language has is well within what you can do for yourself. – John Aug 12 '22 at 03:10

1 Answers1

0

In C#, the or operator is ||. So something like

if (foo == 1 || foo == 2) {
    // do something
}
dmarra
  • 853
  • 8
  • 23