Skip to content

Latest commit

 

History

History
39 lines (26 loc) · 1.16 KB

generate-private-field-from-constructor.md

File metadata and controls

39 lines (26 loc) · 1.16 KB
title description ms.date ms.topic author ms.author manager dev_langs
Generate private field and property from constructor
Learn how to use the Quick Actions and Refactorings menu to generate a private field or property from a constructor.
06/20/2020
reference
mikadumont
midumont
mijacobs
CSharp
VB

Generate private field and property from constructor

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.

How-to

  1. Place your cursor on the parameter name within the constructor.

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

  3. Next, select from one of the following:

  • Create and initialize field or Create and initialize property.

    Generate private field from constructor

See also