A comparison produces a bool — the answer to a yes-or-no question.
| Operator | Asks |
|---|---|
== | are they equal? |
!= | are they different? |
> < | greater / less |
>= <= | greater or equal / less or equal |
Program.cs
using System;
class Program
{
static void Main()
{
int score = 72;
Console.WriteLine(score > 50);
Console.WriteLine(score == 100);
Console.WriteLine(score >= 72 && score < 80);
}
}
Output
True False True
&& means «and» — both sides must be true. || means «or». ! flips a bool.
One equals assigns, two compare
score = 100 puts 100 into score. score == 100 asks whether it is 100.