Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Who is teaching these people?

Who is teaching these people?

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpquestioncomhelp
19 Posts 16 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #1

    From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

    hi
    I have these code . What could cause above error ? Thanks

    state=1
    switch (state)
    {
    case 1:
    //do something

    goto case 2;

    case 2:

    //do something

    goto case 3;

    case 3:
    //do something
    goto case 4;

    ............

    case 100:

    //do something

    }

    OOP language; Fortran programmer.

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    Z M 0 P V 10 Replies Last reply
    0
    • OriginalGriffO OriginalGriff

      From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

      hi
      I have these code . What could cause above error ? Thanks

      state=1
      switch (state)
      {
      case 1:
      //do something

      goto case 2;

      case 2:

      //do something

      goto case 3;

      case 3:
      //do something
      goto case 4;

      ............

      case 100:

      //do something

      }

      OOP language; Fortran programmer.

      Z Offline
      Z Offline
      zlezj
      wrote on last edited by
      #2

      It's a pity that this scheme for line-numbering does not work

      1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

        hi
        I have these code . What could cause above error ? Thanks

        state=1
        switch (state)
        {
        case 1:
        //do something

        goto case 2;

        case 2:

        //do something

        goto case 3;

        case 3:
        //do something
        goto case 4;

        ............

        case 100:

        //do something

        }

        OOP language; Fortran programmer.

        M Offline
        M Offline
        Michael Bookatz
        wrote on last edited by
        #3

        OMG!!!!!!!!!!!!!!!!!!! ripe my eyes out now!!!!!!

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

          hi
          I have these code . What could cause above error ? Thanks

          state=1
          switch (state)
          {
          case 1:
          //do something

          goto case 2;

          case 2:

          //do something

          goto case 3;

          case 3:
          //do something
          goto case 4;

          ............

          case 100:

          //do something

          }

          OOP language; Fortran programmer.

          0 Offline
          0 Offline
          0x3c0
          wrote on last edited by
          #4

          I think a part of me just died. I counted at least 8 things wrong with that snippet

          M OriginalGriffO 2 Replies Last reply
          0
          • 0 0x3c0

            I think a part of me just died. I counted at least 8 things wrong with that snippet

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Not bad there are 9 lines of actual code :laugh:

            Never underestimate the power of human stupidity RAH

            0 1 Reply Last reply
            0
            • M Mycroft Holmes

              Not bad there are 9 lines of actual code :laugh:

              Never underestimate the power of human stupidity RAH

              0 Offline
              0 Offline
              0x3c0
              wrote on last edited by
              #6

              Ah, but only four of those are unique. That works out at 2 errors for each unique line of code

              1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

                hi
                I have these code . What could cause above error ? Thanks

                state=1
                switch (state)
                {
                case 1:
                //do something

                goto case 2;

                case 2:

                //do something

                goto case 3;

                case 3:
                //do something
                goto case 4;

                ............

                case 100:

                //do something

                }

                OOP language; Fortran programmer.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                Other than the missing semi-colon on the first statement, that's how it should be.

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

                  hi
                  I have these code . What could cause above error ? Thanks

                  state=1
                  switch (state)
                  {
                  case 1:
                  //do something

                  goto case 2;

                  case 2:

                  //do something

                  goto case 3;

                  case 3:
                  //do something
                  goto case 4;

                  ............

                  case 100:

                  //do something

                  }

                  OOP language; Fortran programmer.

                  V Offline
                  V Offline
                  VentsyV
                  wrote on last edited by
                  #8

                  Well I have very good idea what happened. The programmer tried to implement fall-through switch, which is not allowed in C#. When he discovered that, he decided to work around it with those goto calls. He was either rusty on his goto or he could not figure how to "declare" a label or maybe the language he was using before did allow something similar... That's what happens when you switch languages. For a while you keep thinking in terms of the old language thus producing such jems.

                  I F 2 Replies Last reply
                  0
                  • V VentsyV

                    Well I have very good idea what happened. The programmer tried to implement fall-through switch, which is not allowed in C#. When he discovered that, he decided to work around it with those goto calls. He was either rusty on his goto or he could not figure how to "declare" a label or maybe the language he was using before did allow something similar... That's what happens when you switch languages. For a while you keep thinking in terms of the old language thus producing such jems.

                    I Offline
                    I Offline
                    I am BATMAN
                    wrote on last edited by
                    #9

                    He shoulda written it recursively :laugh:

                    R 1 Reply Last reply
                    0
                    • 0 0x3c0

                      I think a part of me just died. I counted at least 8 things wrong with that snippet

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #10

                      You missed a couple: 9) Undocumented 10) 100 numeric states. How do you keep track of which one does what...

                      No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

                        hi
                        I have these code . What could cause above error ? Thanks

                        state=1
                        switch (state)
                        {
                        case 1:
                        //do something

                        goto case 2;

                        case 2:

                        //do something

                        goto case 3;

                        case 3:
                        //do something
                        goto case 4;

                        ............

                        case 100:

                        //do something

                        }

                        OOP language; Fortran programmer.

                        S Offline
                        S Offline
                        SalarSoft
                        wrote on last edited by
                        #11

                        OriginalGriff wrote:

                        Fortran programmer.

                        Hehe, he is still alive! :)

                        www.softprojects.org

                        1 Reply Last reply
                        0
                        • V VentsyV

                          Well I have very good idea what happened. The programmer tried to implement fall-through switch, which is not allowed in C#. When he discovered that, he decided to work around it with those goto calls. He was either rusty on his goto or he could not figure how to "declare" a label or maybe the language he was using before did allow something similar... That's what happens when you switch languages. For a while you keep thinking in terms of the old language thus producing such jems.

                          F Offline
                          F Offline
                          Fatbuddha 1
                          wrote on last edited by
                          #12

                          Could easily be c++ -> C# :). But still, this isn't nice in C++ as well.

                          You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

                          1 Reply Last reply
                          0
                          • I I am BATMAN

                            He shoulda written it recursively :laugh:

                            R Offline
                            R Offline
                            Russell Jones
                            wrote on last edited by
                            #13

                            He should have used the for- case pattern ;-)

                            1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

                              hi
                              I have these code . What could cause above error ? Thanks

                              state=1
                              switch (state)
                              {
                              case 1:
                              //do something

                              goto case 2;

                              case 2:

                              //do something

                              goto case 3;

                              case 3:
                              //do something
                              goto case 4;

                              ............

                              case 100:

                              //do something

                              }

                              OOP language; Fortran programmer.

                              R Offline
                              R Offline
                              Russell Jones
                              wrote on last edited by
                              #14

                              state=1 for (int n = state; n<101;n++) { switch (n) { case 1: //do something case 2: //do something case 3: //do something ............ case 100: //do something } } What could be easier than that ;-)

                              1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

                                hi
                                I have these code . What could cause above error ? Thanks

                                state=1
                                switch (state)
                                {
                                case 1:
                                //do something

                                goto case 2;

                                case 2:

                                //do something

                                goto case 3;

                                case 3:
                                //do something
                                goto case 4;

                                ............

                                case 100:

                                //do something

                                }

                                OOP language; Fortran programmer.

                                J Offline
                                J Offline
                                johannesnestler
                                wrote on last edited by
                                #15

                                If the syntax is correctet, the compiler doesn't complain... :laugh: thank you for teaching me that - ;P

                                        int state=1;
                                        switch (state)
                                        {
                                            case 1:
                                            //do something
                                            goto case 2;
                                            
                                            case 2:
                                            //do something
                                            goto case 3;
                                            
                                            case 3: 
                                            //do something
                                            goto case 4;
                                            
                                            case 4://do something
                                            break; // !!!
                                        }
                                
                                L 1 Reply Last reply
                                0
                                • J johannesnestler

                                  If the syntax is correctet, the compiler doesn't complain... :laugh: thank you for teaching me that - ;P

                                          int state=1;
                                          switch (state)
                                          {
                                              case 1:
                                              //do something
                                              goto case 2;
                                              
                                              case 2:
                                              //do something
                                              goto case 3;
                                              
                                              case 3: 
                                              //do something
                                              goto case 4;
                                              
                                              case 4://do something
                                              break; // !!!
                                          }
                                  
                                  L Offline
                                  L Offline
                                  Luc Pattyn
                                  wrote on last edited by
                                  #16

                                  I'm still in favor of

                                    //do something #1
                                    //do something #2
                                    //do something #3
                                    //do something #4
                                  

                                  which compiles just fine. :)

                                  Luc Pattyn [Forum Guidelines] [My Articles]


                                  The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                                  S 1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

                                    hi
                                    I have these code . What could cause above error ? Thanks

                                    state=1
                                    switch (state)
                                    {
                                    case 1:
                                    //do something

                                    goto case 2;

                                    case 2:

                                    //do something

                                    goto case 3;

                                    case 3:
                                    //do something
                                    goto case 4;

                                    ............

                                    case 100:

                                    //do something

                                    }

                                    OOP language; Fortran programmer.

                                    J Offline
                                    J Offline
                                    Jeroen De Dauw
                                    wrote on last edited by
                                    #17

                                    looooool - OMFG, took me a few minutes before I could type again after reading this - ROFL!!!

                                    GSoC 2009 student for SMW! --- My little forums: http://code.bn2vs.com --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!

                                    1 Reply Last reply
                                    0
                                    • L Luc Pattyn

                                      I'm still in favor of

                                        //do something #1
                                        //do something #2
                                        //do something #3
                                        //do something #4
                                      

                                      which compiles just fine. :)

                                      Luc Pattyn [Forum Guidelines] [My Articles]


                                      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                                      S Offline
                                      S Offline
                                      Som Shekhar
                                      wrote on last edited by
                                      #18

                                      Whatever he was trying to do, It results in what Luc has written. Ultimately, he ended up getting the same result with extra lines of code.

                                      1 Reply Last reply
                                      0
                                      • OriginalGriffO OriginalGriff

                                        From the C# questions forum of this very site, I give you: "Why does the compiler complain about falling through the code blocks?" http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=3038975#xx3038975xx[^]

                                        hi
                                        I have these code . What could cause above error ? Thanks

                                        state=1
                                        switch (state)
                                        {
                                        case 1:
                                        //do something

                                        goto case 2;

                                        case 2:

                                        //do something

                                        goto case 3;

                                        case 3:
                                        //do something
                                        goto case 4;

                                        ............

                                        case 100:

                                        //do something

                                        }

                                        OOP language; Fortran programmer.

                                        R Offline
                                        R Offline
                                        Rajesh R Subramanian
                                        wrote on last edited by
                                        #19

                                        Shite! :~ X| Sometimes while reading the programming forums, I just feel like jabbing a fork into my eyes.

                                        It is a crappy thing, but it's life -^ Carlo Pallini

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups