What is the value of C # I=0;i=i++,i?

Source: Internet
Author: User

Reference page:

Http://www.yuanjiaocheng.net/entity/update-entity.html

Http://www.yuanjiaocheng.net/entity/delete-entity.html

Http://www.yuanjiaocheng.net/entity/add-entity-graph.html

Http://www.yuanjiaocheng.net/entity/update-entity-graph.html

Http://www.yuanjiaocheng.net/ASPNET-CORE/first.html

Yesterday saw the group of Dalao chatting, a person came out to ask this question

This question is supposed to be quite common.

int i = 0, t;
for (t = 0;t <= 5;t++)
{
i = i++;
Console.WriteLine (i);
The big guy says for is a disturbance, minus the same. int i = 0;
Console.WriteLine (i = i++); Console.WriteLine (i = i++);   Console.WriteLine (i = i++);   Group inside a lot of people began to say that is will increase, I also feel that will increase, at that time I feel that although I was assigned to 0, then the value of I will be increased, the first output equals 1. And then someone ran, and the result was a bunch of 0. When the expression is processed, the i++ is first processed, that is, the first step is not to assign a value of I to create I ', and then let I self-increment. After the i++ is processed, the lower-level arithmetic of the expression is processed, but I is involved in the operation, and at this time I is assigned to I.         Finally, release the variables created by the system, such as I '. Then there is an upgrade version of the processing of ++i, and i++ exactly the opposite, the system will first give I self-increment processing, and then will be created i ' int i = 0;
Console.WriteLine (i = i++ + ++i);   Console.WriteLine (i = i++ + ++i); The answer to the first output is 2 the second is 6 the first one is 0+2 the second is 2+4 novice beginner, where the wrong also please Dalao pointed out Reprint Please contact

What is the value of C # I=0;i=i++,i?

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.