C# Basic syntax for variable declaration
In C#, the basic syntax for declaring variables is as follows:
<code>数据类型 变量名;</code>
Among them:
- Data type: The type of data stored in the variable, such as int, string, double, etc.
-
Variable name: The name of the variable consists of letters, numbers, and underscores, and must start with a letter.
Example:
<code>int age;
string name;
double salary;</code>
This code declares three variables:
-
age:one Variable to store integers.
-
name: A variable that stores a string.
-
salary: A variable that stores a double-precision floating point number.
Note:
- The variable name cannot be the same as the C# keyword.
- Variable names cannot contain spaces.
- Variables must be declared before use.
- The type of a variable cannot be changed after declaration.
The above is the detailed content of What is the basic syntax of c# variable declaration?. For more information, please follow other related articles on the PHP Chinese website!
Statement: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