Visual Studio constructor creation shortcuts

Visual Studio has shortcuts for almost everything. Getting to know even some of these can save you a lot of time. This post shows examples of some constructor creation shortcuts…

parameterless constructor
type ‘ctor’ and tab twice for parameterless constructor

select which parameters explicitly (shown below)
place cursor at the class level declaration
open ‘Quick Actions’ via the button on the left or Ctrl+. shortcut
Click ‘Generate Constructor’ and select which properties to include

single property constructor
place cursor at the particular property
open ‘Quick Actions’ via the button on the left or Ctrl+. shortcut
Click ‘Generate Constructor ‘Classname(prop type’)’

multiple contiguous properties
select two or more properties
open ‘Quick Actions’ via the button on the left or Ctrl+. shortcut
Click ‘Generate Constructor ‘Classname(prop type, prop type…’)’

Visual Studio constructor shortcuts

Leave a Reply

Your email address will not be published. Required fields are marked *