C# Booleans & Operators

Boolean Values

C# uses the bool type for values that are either true or false.

bool isOnline = true;
bool hasError = false;

Comparison Operators

  • == equal
  • != not equal
  • <, >, <=, >=
Loading...
Output:

Logical Operators

  • && AND
  • || OR
  • ! NOT
Loading...
Output:

Arithmetic Operators

Standard math: +, -, *, /, %

Loading...
Output:

Assignment Operators

  • = assign
  • +=, -=, *=, /=, etc.
Loading...
Output:

Other Operators

  • ++, -- increment/decrement
  • ?: ternary (condition ? true : false)
  • ?? null-coalescing (use fallback if null)
Loading...
Output:

Practice Prompt

What does this print?

Loading...
Output:

Need Help?

Ask the AI if you need help understanding or want to dive deeper in any topic