codeformatter icon indicating copy to clipboard operation
codeformatter copied to clipboard

Constants should be PascalCase

Open FiveTimesTheFun opened this issue 10 years ago • 6 comments

Constant fields, eg:

private const int _ShrinkThreshold = 256;

should be PascalCase.

FiveTimesTheFun avatar Apr 27 '15 16:04 FiveTimesTheFun

Should constants be prefixed with _ even if they're private? :mask:

khellang avatar Apr 27 '15 16:04 khellang

At least for corefx, the decision that was reached was that constants would be pascal-cased and not prefixed with an underscore.

stephentoub avatar Apr 27 '15 16:04 stephentoub

I'm basing this on https://github.com/dotnet/corefx/wiki/Coding-style # 12:

12.We use PascalCasing to name all our constant local variables and fields. The only exception is for interop code where the constant value should exactly match the name and value of the code you are calling via interop.

FiveTimesTheFun avatar Apr 27 '15 16:04 FiveTimesTheFun

:+1: for @stephentoub's comment

khellang avatar Apr 27 '15 16:04 khellang

@FiveTimesTheFun Even local variables?

khellang avatar Apr 27 '15 16:04 khellang

That's from the corefx wiki :) I don't personally disagree with it - that it's constant is more important to me than local vs. field scope.

FiveTimesTheFun avatar Apr 27 '15 17:04 FiveTimesTheFun