Details

Configure Visual Studio to Name Private Fields with Underscore

Here's how to find what you need:

  1. Click on Tools in the menu.
  2. Click on Options.
  3. Click on Text Editor.
  4. Click on C#.
  5. Click on Code Style.
  6. Click on Naming.
  7. Click on Manage naming styles.

Still with me? Now you should see a Naming Style dialog.

Click the plus (+) icon to add a new naming style

Configure the following:

Naming Style Title: _fieldName
Required Prefix: _
Capitalisation: camel Case Name
Sample Identifier: _exampleIdentifier

Click OK twice.

Now click the green plus (+) sign to add a new specification

Choose the following from the 3 dropdown lists:

  • Private or Internal Fields
  • _fieldName
  • Suggestion

Click OK and you're good to go!