Invert if statement
This refactoring applies to:
- C#
- Visual Basic
What: Lets you invert an if
or if else
statement without changing the meaning of the code.
When: When you have an if
or if else
statement that would be better understood when inverted.
Why: Inverting an if
or if else
statement by hand can take much longer and possibly introduce errors. This code fix helps you do this refactoring automatically.
Invert if statement refactoring
Place your cursor in an
if
orif else
statement.Press Ctrl+. to trigger the Quick Actions and Refactorings menu.
Select Invert if.