Editorconfig Guide.e

Prefer expression bodied indexers

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

Prefer expression bodied indexers

csharp-style-expression-bodied-indexers

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

Default value:

false

Possible values:

  • true
  • false
  • when_on_single_line

Examples

true
public int this[int index]
  => _values[index];
false
public int this[int index]
{
  get { return _values[index]; }
}
when_on_single_line
public int this[int index]
  => _values[index];