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.
Math Notation | C# Syntax | Name | Example | Category | Explanation |
---|---|---|---|---|---|
> | > | Greater-than | x > y | Relational | Returns true if x is greater than ... |
Get C# Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.