C # the second day of basic learning (the path to growth of. net cainiao-No foundation to proficient ),

Source: Internet
Author: User

C # the second day of basic learning (the path to growth of. net cainiao-No foundation to proficient ),

1. Use the plus sign in c #. If we want to connect two strings, we can use the plus sign to connect them. If one side of the plus sign is a string, the string serves as a connection. If the plus sign is a number twice, the plus sign adds up.

2. placeholder rules: first open a pit and then fill in a pit. {0. However, if you leave it empty, the program throws an exception. We output data in the order of pitfall, rather than in the order of pitfall.

3. Exceptions the so-called exceptions refer to the absence of errors in the program syntax, but the program crashes and cannot be executed again due to various errors during the program running. Various causes include external and internal factors.

4. Receive user input Console. ReadLine (): This line of code can receive user input in the Console. After receiving the code, we need to store the data entered in the Console. Type? 123 123.123 male 5000 m Zhang San we treat all the data entered by the user in the console as string type, so we can declare a string type variable to receive the user's input in the console. Note: Press enter to continue the program.

5. Three lines of code Console. WriteLine (); output the content in parentheses to the Console. Console. ReadKey (): No matter which key the user presses, the program can continue. Console. ReadLine (): The program can continue only when you press Enter. 6. Concept of Escape Character in c #: the so-called escape character refers to a character with '\' and a "special character. \ B: indicates the backspace key. It does not work if it is placed at the end of the string. \ N: indicates a line feed. It can only wrap in the console \ r \ n: can wrap in the Operating System \ ": represents a double quotation mark \ t: tab, the symbol used to create a table. \: Indicates a '\'. Note: '\' does not represent a character, but an escape @ symbol 1). Cancel the escape Function of '\' in the string, simply represent it as '\'. 2) The string can be output to the console according to the edited original format.

7. Arithmetic Operators +-*/% are called arithmetic expressions by the arithmetic operators. Note: ---> the result of the addition, subtraction, multiplication, division, and remainder of Two integer types is still the integer type ---> the simplest way to increase an integer type to a double type is to multiply it by a 1.0 ---> you can use placeholders. retain the decimal point of the specified number of digits {0: 0. 00 ...}, however, the original value has not changed.

8. Automatic type conversion (implicit type conversion) we require that the types of the operands involved in the operation on both sides of the equal sign must be consistent. If they are inconsistent, the following conditions are met, automatic type conversion will occur (implicit type conversion ). This type of conversion is automatically completed by the compiler, and we do not need to write additional code. ---> Two types of compatibility, for example, int and double compatibility (both numerical) ---> the target type is greater than the source type, for example, double> int number = 10; double d = number; double d = 3.14; int number = d; forced type conversion (display type conversion) ---> two types are compatible: int and double (both numeric) ---> the target type is smaller than the source type, for example, double> int. However, the forced type conversion compiler does not automatically complete the task. We need to manually write code to complete the task. (Type to be converted) the value to be converted; the result of forced type conversion will lose the precision. Whether automatic type conversion or forced type conversion, we must first meet the condition that the data types to be converted are compatible with each other. The compatible data types we have learned are two: double int.

9. If data of incompatible types needs to be converted to Convert type conversion, we use Convert type conversion. To whom you are. Note: Convert type conversion should not be used. It must be replaced. If the conversion is successful, the corresponding value is returned. If the conversion fails, an exception is thrown.

10. The addition, subtraction, and addition of arithmetic operators are divided into the front ++ and the back ++, whether it is the front ++ or the back ++, in the end, the variable itself will be added and subtracted into the front -- and the back --, regardless of the front -- or the back --, the variable itself will eventually be reduced by one

Note: The difference between adding, subtraction, and placing the variable before and after the variable is reflected in the calculation.

Take addition as an example: if it is a forward addition, add one first, and then take the value after adding one to participate in the operation.

If this operation is followed by addition, the original value is used in the operation. After the operation is completed, the original value is added.

For those operators whose +-*/% = requires two operands for operation, we call them binary operators.

For the ++ or -- operator that can be completed by only one person, we call it a unary operator.

Note: the priority of the *** unary operator is higher than that of the binary operator. In an expression, if there are both unary and binary operators, we should first calculate the unary operator. Priority: addition, subtraction, Parentheses, multiplication, division, and Addition

 

 

Video: http://yunpan.cn/cQCnKnKhzCcg5 access password d598

Related Article

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.