ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Generate Type Constructors

Last modified: 26 May 2024

The constructor generation wizard creates a non-default constructor that takes parameters for selected fields , properties and auto-properties.

All generated constructors follow the same pattern where:

  • Each field , property, or auto-property included in the constructor is initialized with a parameter.

  • The name of the parameter is derived from the name of the corresponding field or property.

If there are non-default base type constructors, the required parameters are added to the generated constructor and passed to the base class constructor.

In the example below, this command is used to generate a new Circle constructor that takes two additional parameters to initialize _radius and _center fields.

This feature is supported in the following languages and technologies:

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the Languages and frameworks section.