Home  >  Article  >  Backend Development  >  Naming conventions in C#

Naming conventions in C#

王林
王林forward
2023-08-27 21:17:09980browse

C# 中的命名约定

Class naming convention

The definition of a class begins with the keyword class, followed by the class name; the class body is enclosed by a pair of curly braces. The following is the convention for class names.

Pascal nomenclature

The encoding convention for class names is the name of the class name, for example, Pascal nomenclature should be used.

public class EmployeeDetails {}

Above, the class name EmployeeDetails adopts PascalCasing format.

Noun or noun phrase

Prefer to add the class name as a noun or noun phrase-

public class Employee {}

Identifier is used to identify a class, variable, function or any other user The name of the definition item. The following is the naming convention for identifiers -

  • The name must start with a letter, followed by a sequence of letters, numbers (0 - 9), or underscores. The first character in the identifier cannot be a number.
  • It cannot contain any embedded spaces or symbols, such as ? - ! @#%^&*()[]{}. ; : " ' / and \. However, the underscore ( _ ) can be used.

  • It should not be a C# keyword.

  • ul>

The above is the detailed content of Naming conventions in C#. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete