Local Variable Naming Conventions in .NET [closed]
I know that the naming conventions开发者_Python百科 really don't say anything about that, but I am just curious to know... When you declare a variable local to a given method, do you PascalCase
or camelCase
it?
You'll see camelCase
used more often.
But the most important thing is to use whatever convention you decide on consistently - it'll make your code much easier to read.
I'd vote camelCase
when it comes to local variables:
My understanding so far has been that
PascalCase
is generally used for publicly visible names, whilecamelCase
is used for just about everything else. (I'm aware that this is a very broad generalization. Parameters, for example, are a notable exception to this rule.)When thinking about local variables, I tend to throw them in the same pot as fields and parameters, and these are usually all
camedCased
.
I love to use PascalCase
. But actually it is up to you. Normally I will use longer name that is more descriptive of what the specific variable does. For example:
dim HaveValueIndicator
as boolean = False
dim CountingTheTotalEggs
as int32 = 0
SyleCop has a rule for this: SA1306: FieldNamesMustBeginWithLowerCaseLetter
I beleive this applies to fields and variables.
精彩评论