Back to course

If...Else Conditional Statements

C# Zero to Hero: Comprehensive Programming Masterclass

Logical Decision Making

Use conditional statements to perform different actions based on different conditions.

Syntax

csharp int time = 20; if (time < 12) { Console.WriteLine("Good morning."); } else if (time < 18) { Console.WriteLine("Good afternoon."); } else { Console.WriteLine("Good evening."); }

Comparison Operators

  • == (Equal to)
  • != (Not equal)
  • > (Greater than)
  • < (Less than)