C # Programming--operators (arithmetic operators)

Source: Internet
Author: User
Tags arithmetic operators

Operator types (four classes)

One, arithmetic operators:

a:++--B: */% c: +-

Note: 1. When doing a division, if two numbers are integers, the result is an integer, not a decimal.

2. The above operations, if the two operands are not a type, will be automatically converted at the time of operation

3. Order of operations: first operation a type, then B type, and finally C type (the following operators operate in the same order)

Use of surplus (%):

1. Can be used to determine whether an integer, the remainder is 0 o'clock, is an integer

2. A number used to turn a number into a range

Operations of a++ and ++a

a++: int a=4 b=a++

Console.WriteLine ("A=" +a);

Console.WriteLine ("b=" +b); Result: a=5,b=4 executes b=a, then executes a++ (i.e. a=a+1) when the operation is performed

++a:int a=4 B=++a

Console.WriteLine ("A=" +a);

Console.WriteLine ("b=" +b); Result: A=5,b=5 performs ++a (that is, a=a+1) when the operation is performed, and then executes B=a

Example one:

Example Two

two, relational operators : A. > < >= <= B. == !=         

logic operator :a.&& logic and b. | | Logical OR C.! Logical Non-

iv. assignment operator := + = = *=/= * /

C # Programming--operators (arithmetic operators)

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.