Home > Backend Development > C#.Net Tutorial > Naming conventions in C#

Naming conventions in C#

王林
Release: 2023-08-27 21:17:09
forward
1004 people have browsed it

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 {}
Copy after login

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 {}
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template