When we need to access the information stored in the variable, we only need to use the name of the variable. When you name a variable, follow the rules of the C # language:
Variable names must begin with a letter
Variable names can only consist of letters, numbers, and underscores, and cannot contain spaces, punctuation marks, operators, and other symbols.
Variable names cannot be the same as keyword names in C #. These keywords are given in Appendix A.
The variable name cannot be the same as the library function name in C #.
However, one of the exceptions in C # is that it allows the prefix "@" to be prefixed to the variable name. In this case, we can use the prefix "@" plus the keyword as the name of the variable. This is primarily to avoid conflicts when interacting with other languages. Because the prefix "@" is not actually part of the name, other programming languages will use it as a generic variable name. In other cases, we do not recommend using the prefix "@" as part of the variable name.
Some examples of valid and illegal variable names are given below:
int i; Legal
int No.1; unlawful, containing illegal characters
String Total; Legal
char use; Illegal, same as keyword name
Char @use; Legal
float Main; Illegal, same as function name
Although variable names that meet the above requirements can be used, we still want to give the variable a descriptive name when it is named, so that the written program is easy to understand. For example, the name of a message string can be called S_message, and e90pt is not a good variable name.
We can name multiple variables of the same type in a single statement, such as:
int a,b,c=50,d;