Skip to content
Justice Tech School

C# Comparison and Logical Operators

Comparison operators are == != < > <= >=. Combine tests with && (and), || (or) and ! (not). && and || stop early when the answer is known.

Example
int age = 20; bool member = true;
Console.WriteLine(age >= 18 && member);
Console.WriteLine(age < 18 || !member);
Console.WriteLine(age == 20);

Exercise

And operator.

a  b

Quiz Test

Which means logical or?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.