开发者

Local Variable Naming Conventions in .NET [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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:

  1. My understanding so far has been that PascalCase is generally used for publicly visible names, while camelCase 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.)

  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜