6. Arithmetic operators and arithmetic expressions for C #

Source: Internet
Author: User
Tags arithmetic operators

The C # programming language is very similar to other programming languages, and arithmetic and arithmetic expressions are the same.

1.

+ plus

-Minus

* Multiply

/ except

% Redundancy


These basic arithmetic operators can perform arithmetic operations on constants or variables.


In addition, there are self-increment operators and self-subtraction operators.

++

You can think of + + as the function name, followed by a pair of parentheses, this can be achieved self-increment.

+ + in the front, indicating the first self-increment, and then assign value. + + in the back, indicating the first assignment, and then self-increment.

Like what:

int A;

int b;

b=2;

a=++ (b); increment First, then assign value.

A= (b) + +; The value is first assigned and then self-increment.


-- can be used as a function name, followed by a pair of parentheses, which can effectively enhance readability.

-- before, it means to subtract first and then assign a value. -- after , the expression is first assigned and then reduced.


There are also complex arithmetic operators.

+ = For example:a+=3 is equivalent to a=a+3

-= For example:a-=3 is equivalent to a=a-3

*= such as:a*=3 is equivalent to a=a*3

/= such as:a/=3 is equivalent to A=A/3


6. Arithmetic operators and arithmetic expressions for C #

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.