JetBrains Rider 2022.2 Help

Code Inspection: Use preferred body style (convert to method or operator with preferred body style)

Starting from C# 6.0, you can declare type members using expression bodies, which look very similar to lambda expressions. You can use expression-bodied methods and properties to further simplify the syntax of simple implementations.

If you prefer to stick to either expression-bodied or block-bodied implementations for simple members, JetBrains Rider lets you configure your preferences separately for different kinds of members and maintain the consistency of your preferences throughout your codebase.

For example, let's select Expression body as the preferred style for methods and operators. Accordingly, JetBrains Rider suggests the quick-fix To expression body if a simple method is written with a block body:

public static int MyMethod(int x, int y) { return x * y; }
public static int MyMethod(int x, int y) => x * y;
Last modified: 08 March 2021