O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

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

5.6. if...else Double-Selection Statement

The if single-selection statement performs an indicated action only when the condition is true; otherwise, the action is skipped. The if...else double-selection statement allows you to specify an action to perform when the condition is true and a different action when the condition is false. For example, the pseudocode statement

if grade is greater than or equal to 60         display “Passed” else         display “Failed”

displays “Passed” if the grade is greater than or equal to 60, or “Failed” otherwise. In either case, after displaying occurs, the next pseudocode statement in sequence is “performed.”

The preceding if...else pseudocode statement can be written in C# as

if ( grade >= 60 )    Console.WriteLine( ...

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