Identifiers are character strings used to name things such as variables, methods, parameters, and a host of other programming constructs. It is advisable to create self-documenting identifiers by concatenating meaningful words into a single descriptive name, using uppercase and lowercase letters (FirstName, LastName, MobileNumber, SocialInsuranceNumber and so on). Certain characters are allowed or disallowed at certain positions in an identifier.
- The alphabetic and underscore characters (a through z, A through Z, and _) are allowed at any position.
- Digits (0 to 9) are not allowed in the first position but are allowed everywhere else.
- The @ character is allowed in the first position of an identifier but not at any other position. Although allowed, its use is generally discouraged.
Identifiers are case-sensitive. For instance, the variable names myVarible and MyVariable are different identifiers.
Pascal casing. Each word in the phrase starts with a capital letter. Use for type names and member names visible outside the class. These include the names of the following: classes, methods, namespaces, properties, and public fields.
Camel casing. Each word in the identifier, except the first, starts with a capital letter. Use for local variable names and the names of formal parameters in method declarations.
Camel case with leading underscore. Camel case that starts with an underscore. Use for the names of private and protected fields.
As an aside, there is something called snake case. It refers to the style of writing in which each space is replaced with an underscore (_) character, and the first letter of each word is written in lowercase. In SQL you might use snake_case after the AS to name your columns.
Not everyone agrees with these conventions but one thing is for sure: priority should be given to longer descriptive names rather than short ones that use only parts of words that could be ambiguous. Underscores is that they aren’t generally used in the body of an identifier, except in the names of event handlers,
Keywords
Keywords are the character string tokens used to define the C# language. Keywords cannot be used as variable names or any other form of identifier, unless prefaced with the @ character. All C# keywords consist entirely of lowercase letters. .NET type names, however, use Pascal casing.