patterncsharpCritical
C# naming convention for constants?
Viewed 0 times
conventionconstantsnamingfor
Problem
private const int THE_ANSWER = 42;or
private const int theAnswer = 42;Personally I think with modern IDEs we should go with camelCase as ALL_CAPS looks strange. What do you think?
Solution
The recommended naming and capitalization convention is to use PascalCasing for constants (Microsoft has a tool named StyleCop that documents all the preferred conventions and can check your source for compliance - though it is a little bit too anally retentive for many people's tastes). e.g.
The Pascal capitalization convention is also documented in Microsoft's Framework Design Guidelines.
private const int TheAnswer = 42;The Pascal capitalization convention is also documented in Microsoft's Framework Design Guidelines.
Code Snippets
private const int TheAnswer = 42;Context
Stack Overflow Q#242534, score: 688
Revisions (0)
No revisions yet.