Re: Funny loop with post-increment.

Jon Skeet <[email protected]> Tue, 19 Feb 2008 08:39:36 +0000
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
Brady Kelly wrote:
>> i=i++ is effectively this:
>>
>> int tmp = i;
>> i = i + 1;
>> tmp = i;
>>
>> In other words, the increment happens after the evaluation of i, but
>> before the assignment - so the assignment just sets it back to the
>> original value.
>
> Jon, I have just figured it out the same, but I think you mean your last
> step to be i = tmp, so
>
> i is 0
>
> <begin i++>
> tmp = i
> i += 1
> <end i++>
>
> i = tmp

Absolutely. Sorry about that :)

Jon

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com