How do I customize Visual Studio’s private field generation shortcut for constructors?

This can be also achieved directly in Visual Studio. Just go to Tools -> Options -> Text Editor -> C# -> Code Style -> Naming.

  1. Firstly you need to define a new naming style by clicking the “Manage naming styles” button:

VS2017 Naming style dialog

  1. Then click the + sign to define a new rule for “Private or Internal Field”, that uses your new naming style:

VS2017 Options dialog

  1. Restart Visual Studio

  2. After that, when you apply the “Create and initialize field” refactoring, it will be named with a leading underscore.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)