Head A C # Chinese version chapter II Page63

Source: Internet
Author: User

Before using a variable, you must assign a value to write the following instruction to a C # program: Intz;messagebox.show ("Theansweris" +z);

Go ahead and have a try. You will receive an error and the IDE will refuse to compile the code. That's because the IDE examines each variable to determine that it has been assigned before it is used. The easiest way to prevent forgetting to assign a value is to put the declaration variable and the instruction assigned to it as a sentence.

Some useful types

Each variable has a type, which tells C # what data it can host. In the fourth chapter we will look at more details of types in C #. Now, we're going to focus on these three most popular types. An int is loaded with plastic (or integer), string bearer text, and bool-hosted Boolean value True/false.

If you write a code that uses a variable with no assigned value, the code cannot be compiled. The easiest way to prevent forgetting to assign a value is to declare variables and

The instruction assigned to it is one sentence.

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.