Re: Funny loop with post-increment.
Frans Bouma <[email protected]> Tue, 19 Feb 2008 11:21:18 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <00bd01c872e1$2a4b11b0$7ee13510$@nl> |
> On Feb 19, 2008 8:57 PM, Frans Bouma <[email protected]> wrote: > > It's similar to the old-style C behavior of: Foo(i++, i); > > > > 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. > > eh? I must misunderstand you. Of course c# has ++i. and > i = ++i results in i being equal to 1; Yes, I made a big mistake there, I mistyped some code in my test in snippet compiler so I based a conclusion on a typo. I shouldn't have done that. (I never use ++n so I had to test) > > So apparently the language > > designers thought it would be useful to cram some C-style syntaxis in C# to > > 'make them feel at home' (similar to the retarted 'break;' in case clauses) > > retarded break? i like the break in case statements. what is your > issue with it, out of interest? it doesn't add anything. There's no fall through in C#, so switch(foo) { case 1: // some code case 2: // some code } would have been OK as well. If you forget a break statement, the compiler will whine that you have to place the break there because there's no fall through, however the break statement itself doesn't do anything: there was already a break in the code at that spot. In other places where break is used, it does something: it breaks out of the block it is in, though in switch/case it's unnecessary. FB =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com