C # 's variables

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.