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.