C# Switch statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Duncan McNutt [BSDM]

    #1

    C# Switch statement

    Is it possible to have ranges or patterns in a case ?

    If not, why wasnt this designed in to make it easier instead of listing
    every case value needed?

    --

    Duncan McNutt
    Microsoft Product Deactivation Team
    --




  • Harry Bosch

    #2
    Re: C# Switch statement

    "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote:
    [color=blue]
    > Is it possible to have ranges or patterns in a case ?
    >
    > If not, why wasnt this designed in to make it easier instead of listing
    > every case value needed?[/color]

    You should get a beginner's C# book and start reading it.

    --
    harry

    Comment

    • Duncan  McNutt .[BSDM]

      #3
      Re: C# Switch statement

      I am trying to install MIS 2002 Trial I downloaded from the MS site but I
      get the following errors.

      How can I fix this and get it installing? Any ideas?

      Event Type: Error
      Event Source: MsiInstaller
      Event Category: None
      Event ID: 11720
      Date: 8/17/2003
      Time: 10:09:38 PM
      User: N/A
      Computer: VMWARE2KPRO
      Description:
      Product: Mobile Information Server -- Error 1720.There is a problem with
      this Windows Installer package. A script required for this install to
      complete could not be run. Contact your support personnel or package vendor.
      Custom action IsDCLogon script error -2147023665, : Line 2339, Column 5,

      --

      Duncan McNutt
      Microsoft Product Deactivation Team
      --



      "Harry Bosch" <none@given.com > wrote in message
      news:Xns93DA899 A21702hboschsbc @207.46.248.16. ..[color=blue]
      > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote:
      >[color=green]
      > > Is it possible to have ranges or patterns in a case ?
      > >
      > > If not, why wasnt this designed in to make it easier instead of listing
      > > every case value needed?[/color]
      >
      > You should get a beginner's C# book and start reading it.
      >
      > --
      > harry[/color]


      Comment

      • Duncan  McNutt .[BSDM]

        #4
        Re: C# Switch statement

        oops, wrong thread.

        --

        Duncan McNutt
        Microsoft Product Deactivation Team
        --



        "Duncan McNutt .[BSDM]" <mutmaster@127. 0.0.22> wrote in message
        news:uhr1Y7PZDH A.388@TK2MSFTNG P10.phx.gbl...[color=blue]
        > I am trying to install MIS 2002 Trial I downloaded from the MS site but I
        > get the following errors.
        >
        > How can I fix this and get it installing? Any ideas?
        >
        > Event Type: Error
        > Event Source: MsiInstaller
        > Event Category: None
        > Event ID: 11720
        > Date: 8/17/2003
        > Time: 10:09:38 PM
        > User: N/A
        > Computer: VMWARE2KPRO
        > Description:
        > Product: Mobile Information Server -- Error 1720.There is a problem with
        > this Windows Installer package. A script required for this install to
        > complete could not be run. Contact your support personnel or package[/color]
        vendor.[color=blue]
        > Custom action IsDCLogon script error -2147023665, : Line 2339, Column 5,
        >
        > --
        >
        > Duncan McNutt
        > Microsoft Product Deactivation Team
        > --
        >
        >
        >
        > "Harry Bosch" <none@given.com > wrote in message
        > news:Xns93DA899 A21702hboschsbc @207.46.248.16. ..[color=green]
        > > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote:
        > >[color=darkred]
        > > > Is it possible to have ranges or patterns in a case ?
        > > >
        > > > If not, why wasnt this designed in to make it easier instead of[/color][/color][/color]
        listing[color=blue][color=green][color=darkred]
        > > > every case value needed?[/color]
        > >
        > > You should get a beginner's C# book and start reading it.
        > >
        > > --
        > > harry[/color]
        >
        >[/color]


        Comment

        • Stan

          #5
          Re: C# Switch statement

          Here, I did a search and copied one of the many replies to this common
          question.[color=blue]
          >[/color]

          Yes, like this:

          using System;

          class Test
          {

          public static void Main()
          {
          int x;
          x=Convert.ToInt 16(Console.Read Line());
          switch (x)
          {
          case 1:
          case 2:
          case 3:
          Console.WriteLi ne("Is 1 2 3");
          break;
          case 4:
          case 5:
          case 6:
          Console.WriteLi ne("Is 4 5 6");
          break;
          default:
          Console.WriteLi ne("Is greater than 6");
          break;
          }
          }
          }

          However, you can't do greater than/less than (i.e. case 4 to 6) like
          you could do in VB. You'll have to use if/else statements for that.

          'Lib



          "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
          news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Is it possible to have ranges or patterns in a case ?
          >
          > If not, why wasnt this designed in to make it easier instead of listing
          > every case value needed?
          >
          > --
          >
          > Duncan McNutt
          > Microsoft Product Deactivation Team
          > --
          >
          >
          >
          >[/color]


          Comment

          • Michael A. Covington

            #6
            Re: C# Switch statement


            "Frank Eller [MVP]" <webmaster@fran keller.de> wrote in message
            news:%23G0$M7PZ DHA.1872@TK2MSF TNGP12.phx.gbl. ..
            [color=blue][color=green]
            > > If not, why wasnt this designed in to make it easier instead of listing
            > > every case value needed?[/color]
            >
            > ... here you will have to ask the c# design team.[/color]

            I think they followed C too closely. C, in turn, was designed to be easy to
            compile.


            Comment

            • Edward Yang

              #7
              Re: C# Switch statement

              I love C#. But I strongly disagree with M$ C# team on the design of the
              switch-break statement.

              C# does not allow automatic fall through for each case statement, yet it
              requires a mandatory and useless break statement. It's completely insane to
              have such a design. The break statement is compeletely NOT NECESSARY!

              I understand they want to make programmers make LESS errors by breaking
              C/C++ goodness (e.g., range of values). But those errors caused by
              case-break pair never get in my way throughout 8 years of C/C++ programming
              experience. Actually I've never made a mistake when coding case-break's.

              I think they might want to give a compiler warning when there is no break
              statement after a case statement. That's the best way keeping C/C++ goodness
              yet giving programmers much, much less chance for making errors.

              Edward


              "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
              news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...[color=blue]
              > Is it possible to have ranges or patterns in a case ?
              >
              > If not, why wasnt this designed in to make it easier instead of listing
              > every case value needed?
              >
              > --
              >
              > Duncan McNutt
              > Microsoft Product Deactivation Team
              > --
              >
              >
              >
              >[/color]


              Comment

              • Edward Yang

                #8
                Re: C# Switch statement


                "Frank Eller [MVP]" <webmaster@fran keller.de> wrote in message
                news:%23G0$M7PZ DHA.1872@TK2MSF TNGP12.phx.gbl. ..[color=blue]
                > Hi Duncan,
                >[color=green]
                > > Is it possible to have ranges or patterns in a case ?[/color]
                >
                > No.
                >[/color]

                It is a half yes. See Stan's reply in this thread.
                [color=blue]
                >[color=green]
                > > If not, why wasnt this designed in to make it easier instead of listing
                > > every case value needed?[/color]
                >
                > ... here you will have to ask the c# design team.
                >
                > Regards,
                >
                > --
                > Frank Eller [.NET MVP]
                > www.frankeller.de
                > .NET Developers Group Munich- www.munichdot.net
                >
                >[/color]


                Comment

                • Harry Bosch

                  #9
                  Re: C# Switch statement

                  "Michael A. Covington" <Michael@Coving tonInnovations. com> wrote:
                  [color=blue]
                  > I think they followed C too closely. C, in turn, was designed to be
                  > easy to compile.[/color]

                  It's also because a 'switch' can be optimized a lot better. You are
                  checking a single value against a series of constants, and code can be
                  generated to do that which is faster than the code for the corresponding
                  'if' statements. For instance, the value being checked can be loaded into a
                  register once, and then checked against the constants, which can be
                  immediate data in the opcodes.

                  One could write a compiler to detect that the bunch of 'if's are all
                  checking a single value against a series of constants, and maybe some do
                  that (probably C compilers, if any), and thus get code as good as a
                  'switch'.

                  Also, when a 'switch' uses continuous case values (no gaps), you can build
                  a jump table, which is even better. Lots of C compilers do this.

                  Lexers typically rely on such switch statement optimizations for speed when
                  they handle the next character in the input stream, as an example where it
                  pays off. Of course, the compiler doesn't know you're compiling a lexer, it
                  just generates better code for switches, either way.

                  --
                  harry

                  Comment

                  • Edward Yang

                    #10
                    Re: C# Switch statement

                    OMG, I thought it is not allowed to do this!

                    I read MSDN again, and find this:

                    Although fall through from one case label to another is not supported, it is
                    allowed to stack case labels, for example:
                    case 0:
                    case 1:
                    // do something;
                    Edward

                    "Stan" <stanly12spamre move@yahoo.com. au> wrote in message
                    news:eFxvT3RZDH A.652@tk2msftng p13.phx.gbl...[color=blue]
                    > Here, I did a search and copied one of the many replies to this common
                    > question.[color=green]
                    > >[/color]
                    >
                    > Yes, like this:
                    >
                    > using System;
                    >
                    > class Test
                    > {
                    >
                    > public static void Main()
                    > {
                    > int x;
                    > x=Convert.ToInt 16(Console.Read Line());
                    > switch (x)
                    > {
                    > case 1:
                    > case 2:
                    > case 3:
                    > Console.WriteLi ne("Is 1 2 3");
                    > break;
                    > case 4:
                    > case 5:
                    > case 6:
                    > Console.WriteLi ne("Is 4 5 6");
                    > break;
                    > default:
                    > Console.WriteLi ne("Is greater than 6");
                    > break;
                    > }
                    > }
                    > }
                    >
                    > However, you can't do greater than/less than (i.e. case 4 to 6) like
                    > you could do in VB. You'll have to use if/else statements for that.
                    >
                    > 'Lib
                    >
                    >
                    >
                    > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
                    > news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...[color=green]
                    > > Is it possible to have ranges or patterns in a case ?
                    > >
                    > > If not, why wasnt this designed in to make it easier instead of listing
                    > > every case value needed?
                    > >
                    > > --
                    > >
                    > > Duncan McNutt
                    > > Microsoft Product Deactivation Team
                    > > --
                    > >
                    > >
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Edward Yang

                      #11
                      Re: C# Switch statement

                      Sorry, I want to correct a small part of my comment. See Stan's reply in
                      this thread above this post.

                      C# does allow the old way of 'stacking' case's.

                      <msdn>
                      Although fall through from one case label to another is not supported, it is
                      allowed to stack case labels, for example:
                      case 0:
                      case 1:
                      // do something; </msdn>

                      But do not put any code (comment is OK) after case 0 or case 1, otherwise
                      the non-fall-through compiler error will get you.

                      Edward

                      "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
                      news:%23MRWNcSZ DHA.1620@TK2MSF TNGP12.phx.gbl. ..[color=blue]
                      > I love C#. But I strongly disagree with M$ C# team on the design of the
                      > switch-break statement.
                      >
                      > C# does not allow automatic fall through for each case statement, yet it
                      > requires a mandatory and useless break statement. It's completely insane[/color]
                      to[color=blue]
                      > have such a design. The break statement is compeletely NOT NECESSARY!
                      >
                      > I understand they want to make programmers make LESS errors by breaking
                      > C/C++ goodness (e.g., range of values). But those errors caused by
                      > case-break pair never get in my way throughout 8 years of C/C++[/color]
                      programming[color=blue]
                      > experience. Actually I've never made a mistake when coding case-break's.
                      >
                      > I think they might want to give a compiler warning when there is no break
                      > statement after a case statement. That's the best way keeping C/C++[/color]
                      goodness[color=blue]
                      > yet giving programmers much, much less chance for making errors.
                      >
                      > Edward
                      >
                      >
                      > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
                      > news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...[color=green]
                      > > Is it possible to have ranges or patterns in a case ?
                      > >
                      > > If not, why wasnt this designed in to make it easier instead of listing
                      > > every case value needed?
                      > >
                      > > --
                      > >
                      > > Duncan McNutt
                      > > Microsoft Product Deactivation Team
                      > > --
                      > >
                      > >
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • Michael Culley

                        #12
                        Re: C# Switch statement

                        > experience. Actually I've never made a mistake when coding case-break's.

                        Bullshit.

                        --
                        Michael Culley


                        Comment

                        • Edward Yang

                          #13
                          Re: C# Switch statement

                          1..9 or 1 to 9 seems to be 'clean' code.

                          But, the real truth is that I think the stack of case's is cleaner code.

                          And, as a C/C++ programmer, we guard cautiously our religion principles :-).
                          We do not want to borrow something from another religion.

                          Edward

                          "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
                          news:%238uahxWZ DHA.1280@tk2msf tngp13.phx.gbl. ..[color=blue]
                          > But isnt it more code clean and easier to have
                          >
                          > case 1..9:
                          > or
                          > case 1 to 9:
                          >
                          > instead of
                          >
                          > case 1:
                          > case 2:
                          > case 3:
                          > case 4:
                          > case 5:
                          > case 6:
                          > case 7:
                          > case 8:
                          > case 9:
                          > {
                          > blah();
                          > break;
                          > }
                          >
                          > get my drift?
                          >
                          > I thought C# and .net was about making it more PROBLEM orientated and
                          > elegant solutions, and not house cleaning of code, well this is one case
                          > that they have failed in my view.
                          >
                          >
                          >
                          > --
                          >
                          > Duncan McNutt
                          > Microsoft Product Deactivation Team
                          > --
                          >
                          >
                          > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
                          > news:ulyaMoSZDH A.1872@TK2MSFTN GP12.phx.gbl...[color=green]
                          > > OMG, I thought it is not allowed to do this!
                          > >
                          > > I read MSDN again, and find this:
                          > >
                          > > Although fall through from one case label to another is not supported,[/color][/color]
                          it[color=blue]
                          > is[color=green]
                          > > allowed to stack case labels, for example:
                          > > case 0:
                          > > case 1:
                          > > // do something;
                          > > Edward
                          > >
                          > > "Stan" <stanly12spamre move@yahoo.com. au> wrote in message
                          > > news:eFxvT3RZDH A.652@tk2msftng p13.phx.gbl...[color=darkred]
                          > > > Here, I did a search and copied one of the many replies to this common
                          > > > question.
                          > > > >
                          > > >
                          > > > Yes, like this:
                          > > >
                          > > > using System;
                          > > >
                          > > > class Test
                          > > > {
                          > > >
                          > > > public static void Main()
                          > > > {
                          > > > int x;
                          > > > x=Convert.ToInt 16(Console.Read Line());
                          > > > switch (x)
                          > > > {
                          > > > case 1:
                          > > > case 2:
                          > > > case 3:
                          > > > Console.WriteLi ne("Is 1 2 3");
                          > > > break;
                          > > > case 4:
                          > > > case 5:
                          > > > case 6:
                          > > > Console.WriteLi ne("Is 4 5 6");
                          > > > break;
                          > > > default:
                          > > > Console.WriteLi ne("Is greater than 6");
                          > > > break;
                          > > > }
                          > > > }
                          > > > }
                          > > >
                          > > > However, you can't do greater than/less than (i.e. case 4 to 6) like
                          > > > you could do in VB. You'll have to use if/else statements for that.
                          > > >
                          > > > 'Lib
                          > > >
                          > > >
                          > > >
                          > > > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
                          > > > news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...
                          > > > > Is it possible to have ranges or patterns in a case ?
                          > > > >
                          > > > > If not, why wasnt this designed in to make it easier instead of[/color][/color]
                          > listing[color=green][color=darkred]
                          > > > > every case value needed?
                          > > > >
                          > > > > --
                          > > > >
                          > > > > Duncan McNutt
                          > > > > Microsoft Product Deactivation Team
                          > > > > --
                          > > > >
                          > > > >
                          > > > >
                          > > > >
                          > > >
                          > > >[/color]
                          > >
                          > >[/color]
                          >
                          >[/color]


                          Comment

                          • Duncan  McNutt

                            #14
                            Re: C# Switch statement

                            C# isnt C/C++, thats the point MC++ is just a strap on for .NET C# was
                            designed from the ground up for .NET yet they left things as it was, and now
                            we're gettin partial types and lambada funtions (anonymous methods) expect
                            spaghetii code now, generic types is the only real biggie comming in 04 that
                            I can see, the rest is just gonna cause more problems later on I think.

                            --

                            Duncan McNutt
                            Microsoft Product Deactivation Team
                            --


                            "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
                            news:eSg5z#WZDH A.1384@TK2MSFTN GP10.phx.gbl...[color=blue]
                            > 1..9 or 1 to 9 seems to be 'clean' code.
                            >
                            > But, the real truth is that I think the stack of case's is cleaner code.
                            >
                            > And, as a C/C++ programmer, we guard cautiously our religion principles[/color]
                            :-).[color=blue]
                            > We do not want to borrow something from another religion.
                            >
                            > Edward
                            >
                            > "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
                            > news:%238uahxWZ DHA.1280@tk2msf tngp13.phx.gbl. ..[color=green]
                            > > But isnt it more code clean and easier to have
                            > >
                            > > case 1..9:
                            > > or
                            > > case 1 to 9:
                            > >
                            > > instead of
                            > >
                            > > case 1:
                            > > case 2:
                            > > case 3:
                            > > case 4:
                            > > case 5:
                            > > case 6:
                            > > case 7:
                            > > case 8:
                            > > case 9:
                            > > {
                            > > blah();
                            > > break;
                            > > }
                            > >
                            > > get my drift?
                            > >
                            > > I thought C# and .net was about making it more PROBLEM orientated and
                            > > elegant solutions, and not house cleaning of code, well this is one case
                            > > that they have failed in my view.
                            > >
                            > >
                            > >
                            > > --
                            > >
                            > > Duncan McNutt
                            > > Microsoft Product Deactivation Team
                            > > --
                            > >
                            > >
                            > > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
                            > > news:ulyaMoSZDH A.1872@TK2MSFTN GP12.phx.gbl...[color=darkred]
                            > > > OMG, I thought it is not allowed to do this!
                            > > >
                            > > > I read MSDN again, and find this:
                            > > >
                            > > > Although fall through from one case label to another is not supported,[/color][/color]
                            > it[color=green]
                            > > is[color=darkred]
                            > > > allowed to stack case labels, for example:
                            > > > case 0:
                            > > > case 1:
                            > > > // do something;
                            > > > Edward
                            > > >
                            > > > "Stan" <stanly12spamre move@yahoo.com. au> wrote in message
                            > > > news:eFxvT3RZDH A.652@tk2msftng p13.phx.gbl...
                            > > > > Here, I did a search and copied one of the many replies to this[/color][/color][/color]
                            common[color=blue][color=green][color=darkred]
                            > > > > question.
                            > > > > >
                            > > > >
                            > > > > Yes, like this:
                            > > > >
                            > > > > using System;
                            > > > >
                            > > > > class Test
                            > > > > {
                            > > > >
                            > > > > public static void Main()
                            > > > > {
                            > > > > int x;
                            > > > > x=Convert.ToInt 16(Console.Read Line());
                            > > > > switch (x)
                            > > > > {
                            > > > > case 1:
                            > > > > case 2:
                            > > > > case 3:
                            > > > > Console.WriteLi ne("Is 1 2 3");
                            > > > > break;
                            > > > > case 4:
                            > > > > case 5:
                            > > > > case 6:
                            > > > > Console.WriteLi ne("Is 4 5 6");
                            > > > > break;
                            > > > > default:
                            > > > > Console.WriteLi ne("Is greater than 6");
                            > > > > break;
                            > > > > }
                            > > > > }
                            > > > > }
                            > > > >
                            > > > > However, you can't do greater than/less than (i.e. case 4 to 6) like
                            > > > > you could do in VB. You'll have to use if/else statements for that.
                            > > > >
                            > > > > 'Lib
                            > > > >
                            > > > >
                            > > > >
                            > > > > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
                            > > > > news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...
                            > > > > > Is it possible to have ranges or patterns in a case ?
                            > > > > >
                            > > > > > If not, why wasnt this designed in to make it easier instead of[/color]
                            > > listing[color=darkred]
                            > > > > > every case value needed?
                            > > > > >
                            > > > > > --
                            > > > > >
                            > > > > > Duncan McNutt
                            > > > > > Microsoft Product Deactivation Team
                            > > > > > --
                            > > > > >
                            > > > > >
                            > > > > >
                            > > > > >
                            > > > >
                            > > > >
                            > > >
                            > > >[/color]
                            > >
                            > >[/color]
                            >
                            >[/color]


                            Comment

                            • Edward Yang

                              #15
                              Re: C# Switch statement

                              Yes, there is no absolute EQUALITY in this world. So C# != C/C++. I quite
                              agree.

                              But C# borrows or inherits much of C/C++'s language infrastructures . So what
                              I said in my previous post is applicable to C#.

                              BTW, what is Microsoft Product Deactivation Team? Is it funded by M$? :-p

                              Edward

                              "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
                              news:em6YfCXZDH A.1872@TK2MSFTN GP12.phx.gbl...[color=blue]
                              > C# isnt C/C++, thats the point MC++ is just a strap on for .NET C# was
                              > designed from the ground up for .NET yet they left things as it was, and[/color]
                              now[color=blue]
                              > we're gettin partial types and lambada funtions (anonymous methods) expect
                              > spaghetii code now, generic types is the only real biggie comming in 04[/color]
                              that[color=blue]
                              > I can see, the rest is just gonna cause more problems later on I think.
                              >
                              > --
                              >
                              > Duncan McNutt
                              > Microsoft Product Deactivation Team
                              > --
                              >
                              >
                              > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
                              > news:eSg5z#WZDH A.1384@TK2MSFTN GP10.phx.gbl...[color=green]
                              > > 1..9 or 1 to 9 seems to be 'clean' code.
                              > >
                              > > But, the real truth is that I think the stack of case's is cleaner code.
                              > >
                              > > And, as a C/C++ programmer, we guard cautiously our religion principles[/color]
                              > :-).[color=green]
                              > > We do not want to borrow something from another religion.
                              > >
                              > > Edward
                              > >
                              > > "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
                              > > news:%238uahxWZ DHA.1280@tk2msf tngp13.phx.gbl. ..[color=darkred]
                              > > > But isnt it more code clean and easier to have
                              > > >
                              > > > case 1..9:
                              > > > or
                              > > > case 1 to 9:
                              > > >
                              > > > instead of
                              > > >
                              > > > case 1:
                              > > > case 2:
                              > > > case 3:
                              > > > case 4:
                              > > > case 5:
                              > > > case 6:
                              > > > case 7:
                              > > > case 8:
                              > > > case 9:
                              > > > {
                              > > > blah();
                              > > > break;
                              > > > }
                              > > >
                              > > > get my drift?
                              > > >
                              > > > I thought C# and .net was about making it more PROBLEM orientated and
                              > > > elegant solutions, and not house cleaning of code, well this is one[/color][/color][/color]
                              case[color=blue][color=green][color=darkred]
                              > > > that they have failed in my view.
                              > > >
                              > > >
                              > > >
                              > > > --
                              > > >
                              > > > Duncan McNutt
                              > > > Microsoft Product Deactivation Team
                              > > > --
                              > > >
                              > > >
                              > > > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
                              > > > news:ulyaMoSZDH A.1872@TK2MSFTN GP12.phx.gbl...
                              > > > > OMG, I thought it is not allowed to do this!
                              > > > >
                              > > > > I read MSDN again, and find this:
                              > > > >
                              > > > > Although fall through from one case label to another is not[/color][/color][/color]
                              supported,[color=blue][color=green]
                              > > it[color=darkred]
                              > > > is
                              > > > > allowed to stack case labels, for example:
                              > > > > case 0:
                              > > > > case 1:
                              > > > > // do something;
                              > > > > Edward
                              > > > >
                              > > > > "Stan" <stanly12spamre move@yahoo.com. au> wrote in message
                              > > > > news:eFxvT3RZDH A.652@tk2msftng p13.phx.gbl...
                              > > > > > Here, I did a search and copied one of the many replies to this[/color][/color]
                              > common[color=green][color=darkred]
                              > > > > > question.
                              > > > > > >
                              > > > > >
                              > > > > > Yes, like this:
                              > > > > >
                              > > > > > using System;
                              > > > > >
                              > > > > > class Test
                              > > > > > {
                              > > > > >
                              > > > > > public static void Main()
                              > > > > > {
                              > > > > > int x;
                              > > > > > x=Convert.ToInt 16(Console.Read Line());
                              > > > > > switch (x)
                              > > > > > {
                              > > > > > case 1:
                              > > > > > case 2:
                              > > > > > case 3:
                              > > > > > Console.WriteLi ne("Is 1 2 3");
                              > > > > > break;
                              > > > > > case 4:
                              > > > > > case 5:
                              > > > > > case 6:
                              > > > > > Console.WriteLi ne("Is 4 5 6");
                              > > > > > break;
                              > > > > > default:
                              > > > > > Console.WriteLi ne("Is greater than 6");
                              > > > > > break;
                              > > > > > }
                              > > > > > }
                              > > > > > }
                              > > > > >
                              > > > > > However, you can't do greater than/less than (i.e. case 4 to 6)[/color][/color][/color]
                              like[color=blue][color=green][color=darkred]
                              > > > > > you could do in VB. You'll have to use if/else statements for[/color][/color][/color]
                              that.[color=blue][color=green][color=darkred]
                              > > > > >
                              > > > > > 'Lib
                              > > > > >
                              > > > > >
                              > > > > >
                              > > > > > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
                              > > > > > news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...
                              > > > > > > Is it possible to have ranges or patterns in a case ?
                              > > > > > >
                              > > > > > > If not, why wasnt this designed in to make it easier instead of
                              > > > listing
                              > > > > > > every case value needed?
                              > > > > > >
                              > > > > > > --
                              > > > > > >
                              > > > > > > Duncan McNutt
                              > > > > > > Microsoft Product Deactivation Team
                              > > > > > > --
                              > > > > > >
                              > > > > > >
                              > > > > > >
                              > > > > > >
                              > > > > >
                              > > > > >
                              > > > >
                              > > > >
                              > > >
                              > > >[/color]
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              Working...