coderushforroslyn-115372-refactoring-assistance-combine-split-conditionals.md
Combines two or more neighboring conditionals with identical bodies into a single conditional statement and vice versa. This Refactoring allows you to switch between nested or cascading conditionals and the single conditional with the complex logical expression where each condition is combined with others by the logical AND ( && ) or OR ( || ) operation respectively.
The Combine Conditionals Refactoring is available in the following cases.
The Split Conditional Refactoring is available when the caret is on an if keyword provided that the conditional expression is a complex logical expression where each condition is combined with others by the logical AND ( && ) or OR ( || ) operation.
Place the caret on the if keyword of any of the identical conditions.
Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
Select Combine Conditionals from the menu.
After execution, the Refactoring combines the conditions into one using the logical OR operation.
if (conditionA || conditionB)
return;
If conditionA OrElse conditionB Then
Return
End If
See Also