Configure Visual Studio to Name Private Fields with Underscore
Who else hate having to deal with this.fieldName in new versions of Visual Studio? If you prefer gool ol' underscore prefix, this is for you.
Here's how to find what you need:
- Click on Tools in the menu.
- Click on Options.
- Click on Text Editor.
- Click on C#.
- Click on Code Style.
- Click on Naming.
- 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!