ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Invert 'if' statement to reduce nesting

Last modified: 11 February 2024

Consider the following code snippet:

As you can see, the if blocks encompass the whole body of the method. This presents an opportunity to make code more readable by getting rid of the nested scope as follows: