ReSharper 8.0 Web Help

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

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/property.

If there is a base type constructor with parameters, they are also declared as parameters of the generated constructor and passed to the base class constructor.


You can set up common code generation options in the ReSharper | Options | Code Editing | Members Generation.

To generate a constructor
  1. Position the caret within a type where you would like to generate a constructor.
  2. On the main menu, choose ReSharper | Edit | Generate Code, or press Alt+Insert.
  3. In the Generate pop-up menu, select Constructor.
  4. In the Generate dialog box that appears, select type members that should be initialized in the new constructor. Optionally, select one or several base class constructors. For every selected base constructor, a new constructor will be generated that will call the base and additionally initialize selected members.
    Generating constructors
  5. Optionally, use the Access Rights selector to define access rights for all generated constructors.
  6. Click Finish to complete the wizard. For example, if a single base constructor and a single class member is selected, as shown above, ReSharper generates the following constructor:


To bind any code generation command to its own shortcut, go to Tools | Options | Environment | Keyboard and look for commands starting with ReSharper_Generate.

This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available


The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.