Naming Conventions in C#


Naming convetion for classes

A class definition starts with the keyword class followed by the class name; and the class body enclosed by a pair of curly braces. The following are the conventions for class names.

Pascal Casing

The coding conventions for a class name is the the name of the class names, for example, it should being PascalCasing.

public class EmployeeDetails {}

Above, the class name EmployeeDetails is in PascalCasing.

Noun or Noun Phrases

Prefer adding class names as noun or noun phrases −

public class Employee {}

Identifier is a name used to identify a class, variable, function, or any other user-defined item.The following are the naming convetions for Identifiers −

  • A name must begin with a letter that could be followed by a sequence of letters, digits (0 - 9) or underscore. The first character in an identifier cannot be a digit.

  • It must not contain any embedded space or symbol such as? - + ! @ # % ^ & * ( ) [ ] { } . ; : " ' / and \. However, an underscore ( _ ) can be used.

  • It should not be a C# keyword.

Updated on: 21-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements