coderushforroslyn-115478-refactoring-assistance-flatten-conditional.md
This refactoring helps you simplify conditional clauses and increase code readability in the following cases:
Available when the caret is in an if statement and the surrounding code can be simplified.
Place the caret in a suitable if statement.
Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
Select Flatten Conditional from the menu and press Enter.
After execution, this refactoring simplifies the conditional clauses.
public bool MyBinaryOperator(bool a, bool b)
{
return a && !b;
}
Public Function MyBinaryOperator(ByVal a As Boolean, ByVal b As Boolean) As Boolean
If a AndAlso Not b Then
Return True
End If
Return False
End Function
See Also