if statements

The following table shows all the ways of implementing if statements:

Statement

Description

if/then statement

 An if/then statement consists of a Boolean expression followed by one or more statements.

if/then/else statement

An if/then statement can be followed by an optional else statement, which executes when the Boolean expression is false.

if/then/elif/else statement

An if/then/elif/else statement allows you to have multiple else statements.

Nested if statements

You can use one if or else if statement inside another if or else if statements.

Get .NET Core 2.0 By Example 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.