In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you what the naming rules of variables in C# are, which are concise and easy to understand, which can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. Function: it allows us to store data in the computer.
two。 Syntax: variable type variable name = assignment
3. Common data types:
Value range of int integer type: maximum 2147483647; minimum-2147483648
Value range of double decimal type: maximum 1.79769esig308; minimum-1.79769e+308
String string ""
Char character''
Decimal money type
Bool We use the bool type to describe right or wrong.
True pair
False error
4. Use Rul
Declare first.
Assigning a value
Last use
5. Characteristics
Repeated use of definitions is not allowed
But it can be assigned repeatedly.
6. Naming rules
Must start with a letter, followed by any letter, number, underscore
Naming convention
The Camel camel naming convention requires the first letter of the first word to be lowercase and the first letter of each other word to be capitalized. It is often used to name variables
Pascal requires the first letter of each word to be capitalized and is often used to name classes or methods.
Note: the variable name cannot be a keyword in VS
7. Scope
Local variable
In the method, all the variables we declare are called local variables. The scope of a local variable is the current method
Member variable
In the class, the variables we declare are called member variables. The scope of the member variable is the current class.
The so-called scope refers to the scope that we can use this variable.
C # variable naming convention (naming convention)
The C # naming rules are set to unify the entire program code to enhance its readability. Every organization will write a document of coding specification before developing a software.
There are two common naming methods, one is Pascal nomenclature (Pascal nomenclature), the other is Camel nomenclature (hump nomenclature).
Pascal nomenclature refers to the capitalization of the first letter of each word; Camel nomenclature refers to the lowercase of the first word and the capitalization of the first letter of each word starting with the second word.
1) naming rules for variables
The naming rules of variables follow the Camel nomenclature, and try to use English words that can describe the role of variables. For example, the variable that stores the student's name can be defined as name or studentName, etc. In addition, variable names are not recommended to be too long, preferably 1 word, no more than 3 words at most.
2) naming rules for constants
In order to distinguish from variables, all letters of words that define constants are usually capitalized. For example, the value of n that defines the area of a circle can be defined as a constant to ensure that the value used in the whole program is uniform and can be directly defined as PI.
3) naming rules of the class
The naming rules for classes follow the Pascal naming method, that is, the capitalization of the first letter of each word. For example, define a class that stores student information, which can be defined as Student.
4) naming rules of the interface
The naming convention for the interface also follows the Pascal naming, but it usually starts with an I and capitalizes the first letter of each word that follows it. For example, define an interface for storing value comparison operations, which can be named ICompare.
5) naming rules for methods
The naming of the method follows the Pascal nomenclature and is generally named by verbs. For example, a method that implements the operation of adding user information can be named AddUser.
In the C # language, there are many objects in addition to the above, but the naming rules are similar and will be explained again when other objects are involved.
The above is what are the naming rules of variables in C#. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.