Use expression body or block body for lambda expressions
Applies to: Visual Studio
Visual Studio for Mac
Note
This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
This refactoring applies to:
- C#
What: Lets you refactor a lambda expression to use an expression body or a block body.
When: You prefer lambda expressions to use either an expression body or a block body.
Why: Lambda expressions can be refactored to improve readability according to your user preference.
- Place your cursor on the right of a lambda operator.
- Press Ctrl+. to trigger the Quick Actions and Refactorings menu.
- Select Use block body for lambda expressions or Use expression body for lambda expressions.