Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This refactoring applies to:
What: Convert an if statement to a switch statement or to the C# 8.0 switch expression.
When: You want to convert an if
statement to a switch
statement or a switch
expression and vice versa.
Why: If you are using an if
statement, this refactoring enables an easy transition to switch
statements or switch
expressions.
Place your cursor in the if
keyword.
Press Ctrl+. to trigger the Quick Actions and Refactorings menu.
Select from the following two options:
Select Convert to 'switch' statement.
Select Convert to 'switch' expression.
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today