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

Source: Internet
Author: User

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

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 I watched the dalao chat in the group. Someone asked this question.

This question should be quite common

 

Int I = 0, t;
For (t = 0; t <= 5; t ++)
{
I = I ++;
Console. WriteLine (I );
} Daxie said that for is an interference item, and the removal is also the same as int I = 0;
Console. writeLine (I = I ++); Console. writeLine (I = I ++); Console. writeLine (I = I ++); many people in the group started to say that it will increase, and I thought it would increase. At that time, although I was assigned a value equal to 0, after that, the value of I is increased, and the first output is equal to 1. Then someone ran it again, and the result was that a bunch of zeros were output. When expression processing was performed, I ++ was first processed. That is to say, the first step is not to assign a value to I to create I 'and then let I auto-increment. After I ++ is processed, a lower-level operation of the expression will be performed, but the operation is 'I'. At this time, I will be assigned a value to I. Finally, release the variables created by the system, such as I '. Then there is an upgraded version of the processing for ++ I, which is exactly the opposite of I ++. The system will first perform auto-increment processing for I and then create I 'int I = 0;
Console. writeLine (I = I ++ I); Console. writeLine (I = I ++ I); The first output is 2, the second is 6, the first is 0 + 2, and the second is 2 + 4 for beginners, if anything is wrong, please point it out by dalao. Reprinted please contact

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.