Archive

Posts Tagged ‘Switch’

Generating the Switch/Select statement for enumeration variables

April 30th, 2012 Comments off

CodeRush with Refactor! Pro provides a code provider that allows you to easily generate a switch (C#) or Select (VB) statement for all elements of the enumeration of the active identifier of the enumeration type. The Create Case Blocks from Enum code provider shows a part of the resulting code before applying it. It is possible to apply the code provider on a local variable or a parameter:

Read more…

Refactoring multi-conditional statements: the switch statement and the “if-else-if” ladder

April 30th, 2012 Comments off

There are two methods for multi-conditional processing: the “if-else-if” ladder and the switch statement. The If-Else-If ladder is a combination of ‘if’ and ‘else’ statements that is used to test a series of conditions. If the condition of the first ‘if’ statement is met, the code within the ‘if’ executes. Otherwise, the program flow is passed to the neighborhood ‘else’ statement, in which the next ‘if’ statement is located. This continues as a series of ‘if’ statements nested within the previous ‘else’ statements until all conditions have been checked. A default branch or a code block may be executed in a final ‘else’ statement if no condition is previously met.

Read more…

Code fixes for code issues for switch (select) statements

April 23rd, 2012 Comments off

You might have already learned that CodeRush suggests several code issues that highlight the switch (Select in VB) statement with hints and warnings when it has suspicious code. For example, when the switch statement handles only a subset of the possible enumeration values it is checking for, this may be a sign of incomplete code.

Until recently, there were no code fixes of those code issues. Now, they appear:

Read more…

Navigation between files – Open Files tool window

August 5th, 2011 Comments off

The Open Files CodeRush tool window lists files that are currently opened inside the Visual Studio IDE. The window allows you to quickly switch between files via a single mouse click. This window is similar to the Ctrl+Tab Visual Studio built-in window but has a few advanced options. This is what it looks like:

CodeRush Open Files default view

Read more…