Code snippet or shortcut to create a constructor in Visual Studio

前端 未结 17 1676
悲哀的现实
悲哀的现实 2020-12-23 12:57

What is the code snippet or shortcut for creating a constructor in Visual Studio?

Visual Studio 2010 and C#.

17条回答
  •  清酒与你
    2020-12-23 13:28

    In case you want a constructor with properties, you need to do the following:

    1. Place your cursor in any empty line in a class;

    2. Press Ctrl + . to trigger the Quick Actions and Refactorings menu;

    3. Select Generate constructor from the drop-down menu;

    4. Pick the members you want to include as constructor parameters. You can order them using the up and down arrows. Choose OK.

    The constructor is created with the specified parameters.

    Generate a constructor in Visual Studio

提交回复
热议问题