O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comparison Operators and Boolean Expressions

You have already seen a few of the comparison operators in action. This section presents the six fundamental comparison operators found in C# and explains how they form Boolean expressions.

A comparison operator allows two data values to be compared and generates a result of type bool. If the comparison is true, it produces the bool value true, and it produces the value false if the comparison is untrue.

The six comparison operators, can be divided into two categories—relational and equality. They are all listed in Table 8.1.

Table 8.1. The Six Fundamental Comparison Operators
Math Notation C# Syntax Name Example Category Explanation
> > Greater-than x > y Relational Returns true if x is greater than ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required