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: Redundant 'else' keyword

Last modified: 11 February 2024

Certain if-else conditions can have their else clause removed without changing the semantic. Consider the following method:

In the above, the else statement can be safely removed because its if clause returns from the method. Thus, even without the else, there’s no way you’ll be able to proceed past the if clause body.