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