Remove Redundant Constructor
- 2 minutes to read
Purpose
Removes an empty constructor, if it has no parameters and there are no other constructors in the class. When the class does not contain a constructor, the default one is created internally. The default constructor instantiates the object and sets member variables to the default values as listed in Default Values Table.
Availability
Available when the cursor is on a constructor declaration, provided that the constructor is empty and does not contain parameters. Also, the class should contain no other constructors.
Usage
Place the caret on an empty constructor declaration.
Note
The blinking cursor shows the caret’s position at which the Refactoring is available.
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
- Select Remove Redundant Constructor from the menu.
After execution, the Refactoring removes the constructor.
See Also