I often find I need to remove nesting statements, say an if conditional becomes irrelevant:
if (processFile != null && processFile.Exists)
{
Process[] processesByName = GetProcesses(processFile.NameWithoutExt);
if (processesByName.Length > 0)
{
return processesByName.ToList();
}
}
return null;
Process[] processesByName = GetProcesses(processFile.NameWithoutExt);
if (processesByName.Length > 0)
{
return processesByName.ToList();
}
return null;
The trouble is having to manually find the curly braces on both sides and delete them, while retaining the nested code
Shift+delete
to cut IF
line
Alt+Enter
on bracket to remove redundant braces.
Change the condition to if (true || whatever)
? I think that ReSharper will then tell you that the condition is always true, and will offer to remove it.
One solution, although it might not be ideal:
#region
". #region
#region
title again and select the Resharper option "Remove region/endregion directives".Not a perfect solution, but it should help you get a better overview of what you're doing when working with larger blocks of code than your OP example.
It should look something like this (where the #region
directive can hide any of lines of code):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With