Naming conventions

Throughout the examples used so far, we have seen that some “elements” were named differently than others. By “elements” we mean variables, data fields, properties, methods, constructors, classes, etc. Names of these “elements” are also called identifiers.

There are two basic types of naming conventions used for identifiers.

The first convention is called the PascalCase. In Pascal case the identifiers leave out all the breaks between individual words and make sure every word starts with a capital letter. This might be an example of a Pascal case identifier: “ThisIsPascalCaseIdentifier”.

The second convention is called camelCase. As its name already suggests it is very similar to the Pascal case. The only exception is that the first word starts with a lowercase character. This might be an example of a Camel case identifier: “thisIsCamelCaseIdentifier”.

The Pascal case convention is used for the majority of identifiers within C#. It is used for class names, method names, constructors, etc. It is also used for anything that is accessible outside an already declared class. This means that if we have a public property, it will use the Pascal case. If we have a public data field (although as we have already stated these are usually private), it will use the Pascal case as well.

The Camel case convention on the other hand is used for anything that is private. Private data fields use Camel case. All the variables, as they are in fact all private (scoped to the method in which they have been declared), use the Camel case. All parameters, as they again are all in effect private to the method that received them, use the Camel case.

You can find numerous examples of these conventions in use throughout all of the examples on this website.

Continue to: Language features application

Go up to: Basics


Should you have any questions or found a mistake that needs correcting, feel free to send an email to: info [at] mycsharp [dot] net


Advertisements :