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. General Programming
  3. C#
  4. goto in C#

goto in C#

Scheduled Pinned Locked Moved C#
csharpgame-devquestion
5 Posts 5 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.
  • A Offline
    A Offline
    afronaut
    wrote on last edited by
    #1

    Is this the only way to 'fall through' on switch statements? int x = 3; switch(x){ case 0: goto case 1; case 1: goto case 2; case 2: goto case 3; ... } *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

    L N C 3 Replies Last reply
    0
    • A afronaut

      Is this the only way to 'fall through' on switch statements? int x = 3; switch(x){ case 0: goto case 1; case 1: goto case 2; case 2: goto case 3; ... } *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      yes :) DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET

      1 Reply Last reply
      0
      • A afronaut

        Is this the only way to 'fall through' on switch statements? int x = 3; switch(x){ case 0: goto case 1; case 1: goto case 2; case 2: goto case 3; ... } *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        IMHO something like this would be a cludge that screams poor design. If you need to use goto to 'fall through' a switch then you need to consider redesigning your application. switch(x) { case 0: case 1: case 2: DoAction(); break; . . . } Probably not what your doing though.

        R 1 Reply Last reply
        0
        • N Not Active

          IMHO something like this would be a cludge that screams poor design. If you need to use goto to 'fall through' a switch then you need to consider redesigning your application. switch(x) { case 0: case 1: case 2: DoAction(); break; . . . } Probably not what your doing though.

          R Offline
          R Offline
          ryancrawcour
          wrote on last edited by
          #4

          yeah indeed. perhaps you could consider getting each of your case statements to call functions instead of each other. not sure what your exact need is, but all i know is from previous experience that fallthrough statements come back to bite you in the butt later when you least expect them.

          1 Reply Last reply
          0
          • A afronaut

            Is this the only way to 'fall through' on switch statements? int x = 3; switch(x){ case 0: goto case 1; case 1: goto case 2; case 2: goto case 3; ... } *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            No, you can 'fall' through so long as there is no code between the case statements. And yes, it sucks. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

            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