Re: how 2 multiple case in a switch?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Daniel Jin (anonymous_at_discussions.microsoft.com)
Date: 05/14/04


Date: Fri, 14 May 2004 09:11:08 -0700


     yes you can. C# supports fall through from empty labels

     case 1:
     case 2:
     case 3:
          return true; break;
     case 4:
          return false; break;
     default:
          throw new Exception();

     ----- cody wrote: -----
     
     You can't do that in C#.
     You have to build either a tower of cases of use an "if".
     
     --
     cody
     
     Freeware Tools, Games and Humour
     http://www.deutronium.de.vu || http://www.deutronium.tk
     "Garfield" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag
     news:3F39CCA5-3474-407B-A8FF-70DF19E6ACE3@microsoft.com...
> I have a complex switch statement to build.
> In VB I was able to do something like this:
>> switch (cChar)
> {
> case 32 to 127, 176, 196, 198, 197, 214, 216, 181, 228, 230, 229, 246,
     248:
> return true
> default:
> return false
> }
>> How do I do this without a tower of case labels?
>



Relevant Pages