Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
iforif elsestatement.
Press Ctrl+. to trigger the Quick Actions and Refactorings menu.

Select Invert if.
