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. Break statement in C#.

Break statement in C#.

Scheduled Pinned Locked Moved C#
csharpquestion
10 Posts 7 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.
  • S Offline
    S Offline
    sacoskun
    wrote on last edited by
    #1

    I would like to ask why break statements cannot have labels in C#? For instance; label1: for(;;) { label2: for(;;) { label3: for(;;) { break label2; } } } Kind Regards, Sarp Arda Coskun -- modified at 12:47 Thursday 8th December, 2005

    L A C 3 Replies Last reply
    0
    • S sacoskun

      I would like to ask why break statements cannot have labels in C#? For instance; label1: for(;;) { label2: for(;;) { label3: for(;;) { break label2; } } } Kind Regards, Sarp Arda Coskun -- modified at 12:47 Thursday 8th December, 2005

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What for would you need this?

      S S 2 Replies Last reply
      0
      • L Lost User

        What for would you need this?

        S Offline
        S Offline
        sacoskun
        wrote on last edited by
        #3

        As far as I know Java have this. And it could be beatiful to goto label2 directly for example. Not only a break to one outer loop. Sarp Arda Coskun

        M 1 Reply Last reply
        0
        • S sacoskun

          As far as I know Java have this. And it could be beatiful to goto label2 directly for example. Not only a break to one outer loop. Sarp Arda Coskun

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          You could still use X| goto , but remember: For every goto you use, god kills a kitten! mav

          A 1 Reply Last reply
          0
          • M mav northwind

            You could still use X| goto , but remember: For every goto you use, god kills a kitten! mav

            A Offline
            A Offline
            akyriako78
            wrote on last edited by
            #5

            For god's shake...i haven't used goto since : Amstrad 6-128 BASIC 1.1 Ready | Aaaaahh beautiful recollections of my childhood.

            1 Reply Last reply
            0
            • L Lost User

              What for would you need this?

              S Offline
              S Offline
              Shawn Poulson
              wrote on last edited by
              #6

              Perl does it and it makes sense to me. *shrug* --- Shawn Poulson spoulson@explodingcoder.com

              1 Reply Last reply
              0
              • S sacoskun

                I would like to ask why break statements cannot have labels in C#? For instance; label1: for(;;) { label2: for(;;) { label3: for(;;) { break label2; } } } Kind Regards, Sarp Arda Coskun -- modified at 12:47 Thursday 8th December, 2005

                A Offline
                A Offline
                agileagent
                wrote on last edited by
                #7

                C# is a post C++ and Java language, It took the good from both languages. using labels in code makes it unreadable, using labels is not a good idea. Thats y they got rid of so called labels. :) Work smarter, not harder -- modified at 16:55 Thursday 8th December, 2005

                S 1 Reply Last reply
                0
                • S sacoskun

                  I would like to ask why break statements cannot have labels in C#? For instance; label1: for(;;) { label2: for(;;) { label3: for(;;) { break label2; } } } Kind Regards, Sarp Arda Coskun -- modified at 12:47 Thursday 8th December, 2005

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

                  Man, what you're asking for is damn ugly. If Java has this, I'm glad I don't use Java. Christian Graus - Microsoft MVP - C++

                  S 1 Reply Last reply
                  0
                  • A agileagent

                    C# is a post C++ and Java language, It took the good from both languages. using labels in code makes it unreadable, using labels is not a good idea. Thats y they got rid of so called labels. :) Work smarter, not harder -- modified at 16:55 Thursday 8th December, 2005

                    S Offline
                    S Offline
                    sacoskun
                    wrote on last edited by
                    #9

                    C# has labels and goto statements but not allow labels with break statements. However, I also agree on that it decreases the readibility of the code.

                    1 Reply Last reply
                    0
                    • C Christian Graus

                      Man, what you're asking for is damn ugly. If Java has this, I'm glad I don't use Java. Christian Graus - Microsoft MVP - C++

                      S Offline
                      S Offline
                      sacoskun
                      wrote on last edited by
                      #10

                      Huh, this is the first time that I see the word ugly on a statement, thanks for you comment friend:) Sarp Arda Coskun

                      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