Funny loop with post-increment.

Brady Kelly <[email protected]> Tue, 19 Feb 2008 09:37:59 +0200
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
Why does this loop not exit?  On the first iteration, one would expect i ==
0, and that 0 to be assigned to i, and then i incremented.  Then, on the
second iteration, i should be 1 before the assignment operation, as well as
after the assignment operation, but i should be two after the
post-increment, before the next assignment.



            int i = 0;

            while (i < 10)

            {

                i = i++;

            }


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

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