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

Branching with the if Statement

The if statement comes in different varieties. We will first look at the very basic if statement version (termed the simple if statement) with which you are already familiar.

The Simple if Statement

The syntax of the simple if statement is displayed in Syntax Box 8.1.

Syntax Box 8.1 Simple if-Statement

							Simple_if-statement::=
                       if(<Boolean_expression>)
                           <Statement>;
						

Note

Recall from Chapter 6 that a Boolean expression is always evaluated to one of the two bool values—true and false.

The <Statement> immediately after the Boolean expression will only be executed if the Boolean expression of the if statement is evaluated ...

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