问题
There are a lot of former Java developers at my company who use camel casing in C# for both of these. What casing is most widely accepted / used for C#?
回答1:
Here is the Microsoft Conventions
Here is the full MSDN conventions
And here are the internal guidelines via Brad Abrams (covers just about everything, not just the highlights)
回答2:
The most common casing is camelCasing
.
The Microsoft .NET Framework Reference Guidelines, require method parameters to be in camelCasing, since these are like local variables, I would treat them the same.
回答3:
...and this one...
Internal Coding Guidelines (Design Guidelines, Managed code and the .NET Framework)
I like this one more, there is a clear-cut paragraph on naming/casing. It's only a tad more restrictive.
回答4:
Exactly the same as in Java:
int someVeryLongLocalVariableName;
Official soure:
Camel Casing
The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized.
When an identifier consists of multiple words, do not use separators, such as underscores ("_") or hyphens ("-"), between words. Instead, use casing to indicate the beginning of each word.
The following guidelines provide the general rules for identifiers.
Do use Pascal casing for all public member, type, and namespace names consisting of multiple words.
Note that this rule does not apply to instance fields. For reasons that are detailed in the Member Design Guidelines, you should not use public instance fields.
Do use camel casing for parameter names.
The following table summarizes the capitalization rules for identifiers and provides examples for the different types of identifiers.
来源:https://stackoverflow.com/questions/10020705/what-is-the-correct-casing-convention-for-c-sharp-local-and-instance-variables