Re: Funny loop with post-increment.
Frans Bouma <[email protected]> Tue, 19 Feb 2008 12:31:28 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <00d101c872ea$f7a10da0$e6e328e0$@nl> |
> On Feb 19, 2008 10:18 PM, Frans Bouma <[email protected]> wrote: > [snip] > > > > 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. > > > > No, it's not. > > Yes it is. What if I want to do nothing in case 1, print in case 2, > and do something in the default case? How do I do it without break? Do nothing in case 1 is indeed a good point. THERE a break could mean something, and exactly the same as what break means in if/for/while etc.: break out of the current block. So mandatory requiring a break doesn't do that: it's unnecessary, however requiring a break, you could use break for that, which is precisely why break is in the language. However the breaks in case clauses with code... not necessary. FB > > > > switch(n){ > > case 1: > > case 2: > > Console.WriteLine("a"); > > case 3: > > Console.WriteLine("b"); > > } > > > > would be perfectly fine. As there's no fall through after code > blocks, > > the block of case 1/2 won't end up in the block of case 3. However 'break' > is > > required after the code of case 2. > > > > Anyway, it's never going to change :) > > > > > > 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 DevelopMentorR http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com