Re: Funny loop with post-increment.

silky <[email protected]> Tue, 19 Feb 2008 23:09:13 +1100
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
On Feb 19, 2008 11:01 PM, Jon Skeet <[email protected]> wrote:
> silky wrote:
> >>         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?
>
> Two options:
>
> 1) Don't include the case

Won't work because then you'll hit the default case.


> 2) Use a pair of empty braces, just like you would if you wanted to do
> nothing in a catch block:

Okay, I will believe you that that works :)


> switch (n)
> {
>      case 1:
>      {
>      }
>      case 2:
>      {
>         Console.WriteLine("Foo");
>      }
>      default:
>      {
>         // Whatever
>      }
> }
>
> Jon

--
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