Build the Foundation on the 7th day -- C # the next day

Source: Internet
Author: User

The last time we talked about variables, they can be said to be the basis of programming. The main function is to store data, just like cooking. Different dishes should be placed in different types of containers, different data must also be stored in different types of variables. Put a picture of the food to show you how to increase your appetite.

It can be seen that the various dishes (data) are placed in the corresponding container (variable) very harmonious, if you have to put the fish in the lower left corner in the bowl of rice, it is not impossible, but it looks awkward. In addition, if you have to use the spoon in the lower right corner to drink the soup, I also wish you good patience.

In C #, we also need to store different data in different types of variables. For example, integers such as "13, 34, and 632" are saved using int type variables, decimals such as "23.4 and 87.24" (called floating point numbers in C #) are generally saved using double-type variables. Strings such as "Brazil Germany" are saved using string-type variables. There are some other types that we will introduce later. How to use these types? Let's look at an example:

The second step is to add food to the dish. In the previous step, we assigned variable values directly in the program, but in actual development, many occasions, we will give an input port to the program. For example, a text box for entering the account and password is provided during logon. Similar to the data entry, different data is stored in different variables through this entry. The Code is as follows:

Press Ctrl + F5 to perform the following operations:

Let's talk about it today. Let's take a good look at it and know what variables are, how to define variables, how to assign values to variables, and how to display values in variables.

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.