Convert switch statement to switch expression
This refactoring applies to:
When: You want to convert a
switch statement to a
switch expression and vice versa.
Why: If you are only using expressions, this refactoring enables an easy transition from traditional
In your project file, set the language version to preview since
switchexpressions are a new C# 8.0 feature.
Place your cursor in the
switchkeyword and press Ctrl+. to trigger the Quick Actions and Refactorings menu.
Select Convert switch statement to expression.