Re: Funny loop with post-increment.

Jon Skeet <[email protected]> Tue, 19 Feb 2008 10:08:42 +0000
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
Frans Bouma wrote:

<snip>

>         x is 1, not 0. So replacing i=i+1 with i++ (even when there are
> brackets) makes the code change, while i=i+1 is thought to be the equivalent
> of i++.

That's your mistake - assuming that i++ is equivalent to i=i+1. It's
not, that's the pre-increment behaviour.

If people don't learn the difference between i++ and ++i but use them
anyway, how is that the language's fault?

>         where i is first passed and then incremented. However, what's silly is
> that in C you had ++i as well, but in C# you don't.

Um, in what way? ++i is perfectly valid, and *is* equivalent to i=i+1.

Jon

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

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