Editorconfig Guide.e

Prefer primary constructors

EditorConfig key: csharp-style-prefer-primary-constructors

Prefer primary constructors

csharp-style-prefer-primary-constructors

This option controls whether primary constructors should be preferred over traditional constructors when they would suffice.

Default value:

true

Possible values:

  • true
  • false

Examples

true
class Person(string name) { }
false
class Person
{
  public Person(string name) { this.name = name }
}