ReSharper Help  

Generating Type Constructors

Selecting Constructor from the Generate Code popup menu causes Generate Constructor dialog to appear.

The dialogs allows you to select the fields you want to be initialized in the constructor, as well as to choose the desired access class. Should a type be derived from some other type that has several constuctors, the following dialog will be displayed first, allowing you to select the base class constructor to be invoked:

All generated constructors follow the same pattern. Each of the selected fields is initialized using the corresponding parameter. Should there be a base type constructor with parameters, they will also be declared as parameters of the generated constructor and passed to the bas class constructor. Consider the following code example:

We have choosen to generate a constructor invoking a Stack(int) base class constructor, and initializing two fields myInt and myString. The following constructor is generated in this case:

Note   If the class where you want to generate a constructor has no fields and if its superclass (if any) has only one constructor the constructor will be generated but no dialogs will appear.

See Also

Advanced Editing Features | Automatic Code Generation | Generating Properties | Implementing/Overriding Methods