O'Reilly logo

Start Here!™ Fundamentals of Microsoft® .NET Programming by Rod Stephens

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

Conditional Statements

Conditional statements let a program take different actions depending on the circumstances. These statements include several versions of If statements. Most languages also include a Case statement, which is a simpler way of writing a series of If statements.

If

The simple If statement executes a code block only if some condition is true. The following shows the If statement’s pseudocode:

If <condition>
    Do something...

If <condition> is true, the program executes the code block. If <condition> is false, the program skips the code block and executes the code that follows.

If Else

The If Else statement executes one of two code blocks depending on a condition’s value. The following shows the If Else statement’s pseudocode:

If <condition> ...

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