Knowledge of variables and constants is the basic knowledge of a programming language, and each programming language has its own naming and usage of variables and constants. This chapter explains variables and constants in the C # language, including the purpose of variables and constants, how to name variables and constants, and how to define and initialize variables and constants.
5.1 Variables
The program should read, write, and operate the data. When you need to save a particular value or calculate a result, you need to use a variable (variable). In the view of the user, the variable is used to describe the name of a message, in the variable can store various types of information, such as: the name of the person, ticket prices, the length of the file, and so on.
In a computer, a variable represents a store address, and the type of the variable determines the type of numeric value stored in the variable. C # is a secure type language whose compiler stores the values in a variable with the appropriate data type. The value of a variable can be changed after the assignment or the "+ +" and "--" operators are evaluated.
One important principle of using variables is that variables must be defined before they are used.
A variable can be assigned at the time it is defined, or it can be defined without being assigned a value. A variable that is assigned to a definition well defines an initial value. A variable that is not assigned a value at the time of definition has no initial value. Assigning a variable that has not been assigned a value must be performed in an executable code.
5.1.1 Named variables
5.1.2 C # Variable type