Naming Convention In C#

The naming convention is a set of rules that help developers to make readable and clean codes.

Capitalization

There are two ways to distinguish words within names:

  • PascalCasing
  • CamelCasing

With PascalCasing convention, the first character of every word in the identifier is upper case. We use PascalCasing convention for almost all identifiers including namespaces, classes, interfaces, constructors, protected fields, constant variables, methods, properties, delegates, events, and enumerations.

With camelCasing convention, the first character of the first word in the identifier is lowercase, while the first character of every subsequent word is uppercase. We use camelCasing convention for internal and private fields, local variables as well as parameters.

Word Selection

Class & Struct Names
 - Nouns or noun phrases
 - Adding full or part of the base class name as a suffix to the name of the derived class to show the relationship between classes
 - Adding suffixes that show the technical pattern of the class
Name of the Interfaces
 - Nouns or noun phrases
 - Beginning with the letter I
 - When representing capabilities, the name of the interfaces are adjectives or adjective phrases
Method Names
 - Verbs or verb phrases
Name of Fields and Properties
 - Nouns, noun phrases, or adjectives
 - For boolean fields and properties use Is, Can, or Has prefixes
 - When a field or property is a type of collection, make its name plural
Events
 - Verbs and verb tenses

For more information please watch this video on YouTube.