| title | Generate private field and property from constructor | ||
|---|---|---|---|
| description | Learn how to use the Quick Actions and Refactorings menu to generate a private field or property from a constructor. | ||
| ms.date | 06/20/2020 | ||
| ms.topic | reference | ||
| author | mikadumont | ||
| ms.author | midumont | ||
| dev_langs |
|
This refactoring applies to:
- C#
What: Generate a private field or property from a constructor.
When: You want to quickly add and initialize a private field or property from a constructor.
Why: Writing private fields and properties can be time consuming and repetitive. Using this refactoring is quick and makes the program more robust.
-
Place your cursor on the parameter name within the constructor.
-
Press Ctrl+. to trigger the Quick Actions and Refactorings menu.
-
Next, select from one of the following:
