Home > Coding Helpers > Coding Helpers – Add Else Statement

Coding Helpers – Add Else Statement

August 15th, 2012

The Add Else Statement code provider performs the operation its name implies – it generates the ‘else’ statement of the current conditional statement. The ‘else’ statement is required when you want to execute a piece of code if a condition is not met. In other words, the ‘else’ is useful when an alternative case is required on the ‘if’ statement.

Apply the code provider on any ‘if’ statement:

CodeRush Add Else Statement preview

This will add an additional conditional clause:

CodeRush Add Else Statement result

Now, if the boolean condition is false, the alternative else branch is executed. The code provider may save you a few keystrokes while entering the statement with curly braces in C# and navigate inside it. In Visual Basic, it will generate the corresponding If .. End If code.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Aug/15/2012
ID: C177

Similar Posts: