Private field naming convention
See original GitHub issueIn this issue I’d like to align the private field name convention in our project.
I’ve found that in one places we prefix private fields with underscore, while in other we don’t. That is a pretty confusing and we should align the single styling for this project.
Usually, I prefer to start private fields with the underscore character:
private class SomeClass
{
private readonly int _someValue;
public SomeClass(int value)
{
this._someValue = value;
}
}
However I would be fine if we agree to live without them (like most of the code is written in kernel) as we enforce the this
keyword (so it’s clear that it’s the field):
private class SomeClass
{
private readonly int someValue;
public SomeClass(int value)
{
this.someValue = value;
}
}
@moodmosaic @adamchester Do you have any opinion regarding the naming convention? I’m fine with whatever we follow - the only wish is to have a consistency.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
C# Field Naming Guidelines?
Following Microsoft's naming conventions, private fields should be prefixed with an underscore. For example: private int _myValue;. Good luck!
Read more >Naming Convention for Private / Public Fields [duplicate]
Convention for naming private instance fields is up to you but it should be consistent in the whole project (or all company projects)....
Read more >NET documentation C# Coding Conventions
Learn about commonly used coding conventions in C#. Coding conventions create a consistent look to the code and facilitate copying, ...
Read more >Configure Visual Studio to Name Private Fields with ...
Configure Visual Studio to Name Private Fields with Underscore · Click on Tools in the menu. · Click on Options. · Click on...
Read more >Naming convention for private static fields? : r/dotnet
Docs seem to point out that all static fields should start with uppercase and no prefix, but also they point out that all...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, I don’t believe in that 😃 However, who knows… 😏
Sounds like they’re coming from VB? 😉