Invert if refactor available in Visual Studio

When writing code try and form your if conditionals in positive language as developers find it easier to think about the way things are rather than the way they are not.

If you have if/else blocks which test a negative scenario first consider inverting the blocks. Visual Studio has an invert if refactor available to help with this so we don’t have to manually reorganize our code blocks.¬†

To see the refactor option in Visual Studio just click on the line with the if statement in it…

Leave a Reply

Your email address will not be published. Required fields are marked *