2 ms·
> In C#, this confusion is possible, if you name your private members the same way as your locals. This is also an issue with own methods versus static imports
by masklinn 6y ago
> In C#, this confusion is possible, if you name your private members the same way as your locals.
This is also an issue with own methods versus static imports.
> Microsoft recommends and uses a convention which does exactly this. [1][2]
The article mentions this:
> I know, capitalization conventions change over time, and I could have sworn there was a time when camel casing was the recommended approach for fields (specifically private fields)
It looks like "private fields" (along with private everything) have been completely dropped from the conventions: https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions https://docs.microsoft.com/en-us/dotnet/standard/design-guid...
Only parameters remain conventionally camelCased, and it makes sense that they remain specified as C# allows for named parameters (so parameter names are part of the public interface).
- jayd16 6y agoNaming of fields and other members is described here https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-type-members https://docs.microsoft.com/en-us/dotnet/standard/design-guid... Pascal case, same as Properties so they can be seamlessly refactored.
- masklinn 6y ago> Naming of fields and other members is described here https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-type-members https://docs.microsoft.com/en-us/dotnet/standard/design-guid... Your link explicitly states that it does not cover private fields: > Internal and private fields are not covered by guidelines Which is specifically what I noted was dropped from the document linked by TFA. > Pascal case, same as Properties so they can be seamlessly refactored. Your link also explicitly states that it only applies to static public or protected fields, and that public instance fields are forbidden by the member design guidelines*: > The field-naming guidelines apply to static public and protected fields […] public or protected instance fields are not allowed by the member design guidelines. So the only "seamless refactoring" which is allowed is essentially irrelevant (it's switching between static fields and static properties).
- jayd16 6y agoMy comment was meant to be additive and not in conflict with any of your statements.