Re: Funny loop with post-increment.
silky <[email protected]> Tue, 19 Feb 2008 21:40:30 +1100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
On Feb 19, 2008 9:21 PM, Frans Bouma <[email protected]> wrote: > > 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. there is indeed faltlhrough, just not fallthrough when you have code in one: switch(n){ case 1: case 2: Console.WriteLine("a"); break; } // ^^ valid switch(n){ case 1: Console.WriteLine("m"); case 2: Console.WriteLine("x"); break; } // ^^ invalid > 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. it is necessary given the above. > FB -- http://lets.coozi.com.au/ A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com