Editorconfig Guide.e

Prefer expression bodied operators

EditorConfig key: csharp-style-expression-bodied-operators

Prefer expression bodied operators

csharp-style-expression-bodied-operators

This option controls whether operator methods should be written using expression-bodied syntax.

Default value:

false

Possible values:

  • true
  • false
  • when_on_single_line

Examples

true
public static Person operator +(Person a, Person b)
  => new Person(a.Name + b.Name);
false
public static Person operator +(Person a, Person b)
{
  return new Person(a.Name + b.Name);
}
when_on_single_line
public static Person operator +(Person a, Person b)
  => new Person(a.Name + b.Name);