A condition is an expression that can be either true or false. This section introduces a simple version of C#’s if statement that allows an app to make a decision based on the value of a condition. For example, the condition “grade is greater than or equal to 60” determines whether a student passed a test. If the condition in an
if statement is true, the body of the
if statement executes. If the condition is false, the body does not execute. We’ll see an example shortly.
if statements can be formed by using the equality operators (== and !=) and relational operators (>, <, >= and <=) summarized in Fig. 3.21. The two equality operators (== and !=) each have the same level of ...