Capitalization Conventions

Terminology

Camel Case (camelCase)In this standard, the first letter of the word always in small letter and after that each word starts with a capital letter.
Pascal Case (PascalCase)In this the first letter of every word is in capital letter.
Underscore Prefix (_underScore)For underscore ( _ ), the word after _ use camelCase terminology.
Hungarian CaseThe data type as prefix is used to define the variable by developers long ago. Examples: string m_sName; string strName; int iAge;

Identifiers

  • DO use PascalCasing for all public member, type, and namespace names consisting of multiple words.
  • DO use camelCasing for parameter and local variable names.
  • DO use _underScore for private, protected, internal, and protected internal property and field names.
  • DO use PascalCasing or camelCasing (Depending on the identifier type) for abbreviations 3 characters or more (2 chars are both uppercase when PascalCasing is appropriate or inside the identifier):
HtmlHelper htmlHelper;
FtpTransfer ftpTransfer, fastFtpTransfer;
UIControl uiControl, nextUIControl;

Naming convention is unaffected by modifiers such as const, static, readonly, etc.

IdentifierCasingExample
NamespacePascalnamespace System.Security { // ... }
TypePascalpublic class StreamReader { ... }
InterfacePascalpublic interface IEnumerable { ... }
MethodPascalpublic virtual string ToString() { ... }
PropertyPascalpublic string Name { get { ... } }
EventPascalpublic event EventHandler Exited;
Public FieldPascalpublic static readonly TimeSpan InfiniteTimeout;
Public ConstPascalpublic const Min = 0;
Private Field_underScoreprivate string _url;
Enum ValuePascalpublic enum FileMode { Append, ... }
ParameterCamelpublic static int ToInt32(string value);

Rules for Compound Words

  • DO Follow these examples about compound words:
PascalCasecamelCaseIncorrect Format
BitFlagbitFlagBitflag
Callback [1]callbackCallBack
CanceledcanceledCancelled
DoNotdoNotDon’t
EmailemailEMail
Endpoint [1]endpointEndPoint
FileNamefileNameFilename
Gridline [1]gridlineGridLine
Hashtable [1]hashtableHashTable
IdidID
IndexesindexesIndices
LogOfflogOffLogOut
LogOnlogOnLogIn
Metadata [1]metadataMetaData
Multipanel [1]multipanelMultiPanel
Multiview [1]multiviewMultiView
Namespace [1]namespaceNameSpace
OkokOK
PipiPI
PlaceholderplaceholderPlaceHolder
SignInsignInSignOn
SignOutsignOutSignOff
UserNameuserNameUsername
WhiteSpacewhiteSpaceWhitespace
WritablewritableWriteable

Footnote

[1] These are what are called closed-form compound words and should be treated as a single word. If you would write it as a single word in a sentence, do so in an identifier as well.

Case Sensitivity

  • DO NOT vary identifiers based solely on capitalization. The CLR in general does not require that identifiers vary based on sensitivity (Age is the same as age). C# does support it (as it is a C type language).
// Bad
class Person {
    public int age { get; set; }
    public int Age { get; set; }
}

Learn More