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. The Lounge
  3. Damn c# { }'s

Damn c# { }'s

Scheduled Pinned Locked Moved The Lounge
csharpquestioncareer
68 Posts 47 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.
  • R Offline
    R Offline
    RossMW
    wrote on last edited by
    #1

    Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

    M D J M P 33 Replies Last reply
    0
    • R RossMW

      Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      I find that after spending a day doing Ruby programming, my soul cries out to at least write a few lines of C# code in the evening. Ah... But to your question, my fingers are so programmed to type {} whenever I write a method, I can't really help you there. In fact, in Ruby where occasionally one does use {} I get really pissed off at the IDE for auto-completing the closing }. Or ] or ). Hmmm...I bet there's a way to kill that in RubyMine. :) Marc

      Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

      R 1 Reply Last reply
      0
      • M Marc Clifton

        I find that after spending a day doing Ruby programming, my soul cries out to at least write a few lines of C# code in the evening. Ah... But to your question, my fingers are so programmed to type {} whenever I write a method, I can't really help you there. In fact, in Ruby where occasionally one does use {} I get really pissed off at the IDE for auto-completing the closing }. Or ] or ). Hmmm...I bet there's a way to kill that in RubyMine. :) Marc

        Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

        R Offline
        R Offline
        RossMW
        wrote on last edited by
        #3

        I main problem I seem to is after a lot of if, Switch or whatever and you end up with a lot of

        }
        }
        }
        }

        and then trying to figure which } belong with which {

        M H L K U 5 Replies Last reply
        0
        • R RossMW

          Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

          D Offline
          D Offline
          Duncan Edwards Jones
          wrote on last edited by
          #4

          Left brace, right brace, back arrow, code...

          R M A 4 Replies Last reply
          0
          • D Duncan Edwards Jones

            Left brace, right brace, back arrow, code...

            R Offline
            R Offline
            RossMW
            wrote on last edited by
            #5

            Sounds like a dance move, cha cha cha

            D 1 Reply Last reply
            0
            • D Duncan Edwards Jones

              Left brace, right brace, back arrow, code...

              M Offline
              M Offline
              Marc Clifton
              wrote on last edited by
              #6

              Duncan Edwards Jones wrote:

              Left brace, right brace, back arrow, code...

              Exactly! Marc

              Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

              1 Reply Last reply
              0
              • R RossMW

                I main problem I seem to is after a lot of if, Switch or whatever and you end up with a lot of

                }
                }
                }
                }

                and then trying to figure which } belong with which {

                M Offline
                M Offline
                Marc Clifton
                wrote on last edited by
                #7

                RossMW wrote:

                and then trying to figure which } belong with which {

                Dang, doesn't the IDE (dimly, I'll grant) light up the matching braces? [on my high horse] If you have that much nesting, maybe you should break the function apart into smaller calls? [/on my high horse] Marc

                Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

                R Sander RosselS M T 4 Replies Last reply
                0
                • M Marc Clifton

                  RossMW wrote:

                  and then trying to figure which } belong with which {

                  Dang, doesn't the IDE (dimly, I'll grant) light up the matching braces? [on my high horse] If you have that much nesting, maybe you should break the function apart into smaller calls? [/on my high horse] Marc

                  Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

                  R Offline
                  R Offline
                  RossMW
                  wrote on last edited by
                  #8

                  Yes, very dimly. Makes it hide to find when you have to scroll to see it. Just have to remember the Left brace, right brace, back arrow, code... dance move...

                  S M 2 Replies Last reply
                  0
                  • R RossMW

                    Sounds like a dance move, cha cha cha

                    D Offline
                    D Offline
                    Duncan Edwards Jones
                    wrote on last edited by
                    #9

                    That it pretty much is - definitely muscle memory at this stage.

                    D 1 Reply Last reply
                    0
                    • R RossMW

                      Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

                      J Offline
                      J Offline
                      Jeremy Falcon
                      wrote on last edited by
                      #10

                      Spend more time coding in C-style syntaxes rather than BASIC style ones. We're creatures of habit and muscle memory doesn't make this issue any better.

                      Jeremy Falcon

                      1 Reply Last reply
                      0
                      • M Marc Clifton

                        RossMW wrote:

                        and then trying to figure which } belong with which {

                        Dang, doesn't the IDE (dimly, I'll grant) light up the matching braces? [on my high horse] If you have that much nesting, maybe you should break the function apart into smaller calls? [/on my high horse] Marc

                        Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

                        Sander RosselS Offline
                        Sander RosselS Offline
                        Sander Rossel
                        wrote on last edited by
                        #11

                        Actually that's a closing brace for your namespace, class, method and if statement. Not much nesting at all, it just looks that way in C# :) This is where I'd usually sing some VB praise, but having been away from VB for far too long I'm just not in the mood :laugh:

                        Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                        Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                        Regards, Sander

                        M R 2 Replies Last reply
                        0
                        • Sander RosselS Sander Rossel

                          Actually that's a closing brace for your namespace, class, method and if statement. Not much nesting at all, it just looks that way in C# :) This is where I'd usually sing some VB praise, but having been away from VB for far too long I'm just not in the mood :laugh:

                          Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                          Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                          Regards, Sander

                          M Offline
                          M Offline
                          Marc Clifton
                          wrote on last edited by
                          #12

                          Sander Rossel wrote:

                          Actually that's a closing brace for your namespace, class, method and if statement.

                          Heh, good point. I usually never pay much attention to those. :) Marc

                          Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

                          1 Reply Last reply
                          0
                          • R RossMW

                            Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

                            M Offline
                            M Offline
                            Mark_Wallace
                            wrote on last edited by
                            #13

                            Rotate your monitor 90 degrees, to portrait orientation. No kidding.

                            I wanna be a eunuchs developer! Pass me a bread knife!

                            R 1 Reply Last reply
                            0
                            • R RossMW

                              Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

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

                              Consistent formatting.

                              1 Reply Last reply
                              0
                              • Sander RosselS Sander Rossel

                                Actually that's a closing brace for your namespace, class, method and if statement. Not much nesting at all, it just looks that way in C# :) This is where I'd usually sing some VB praise, but having been away from VB for far too long I'm just not in the mood :laugh:

                                Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                                Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                                Regards, Sander

                                R Offline
                                R Offline
                                RossMW
                                wrote on last edited by
                                #15

                                It's one of the advantages of VB in that the end states what it's the end of. I think that just makes me a bit lazy on the formatting before coding.

                                1 Reply Last reply
                                0
                                • M Mark_Wallace

                                  Rotate your monitor 90 degrees, to portrait orientation. No kidding.

                                  I wanna be a eunuchs developer! Pass me a bread knife!

                                  R Offline
                                  R Offline
                                  RossMW
                                  wrote on last edited by
                                  #16

                                  I have been tempted to rotate one of my two monitors, but I have to do other stuff which is best in landscape. Maybe I need more monitors! Keep up that winter tan...

                                  1 Reply Last reply
                                  0
                                  • R RossMW

                                    Yes, very dimly. Makes it hide to find when you have to scroll to see it. Just have to remember the Left brace, right brace, back arrow, code... dance move...

                                    S Offline
                                    S Offline
                                    Sascha Lefevre
                                    wrote on last edited by
                                    #17

                                    You can change the color of the highlighting :) clicky[^]

                                    If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                    R D 2 Replies Last reply
                                    0
                                    • S Sascha Lefevre

                                      You can change the color of the highlighting :) clicky[^]

                                      If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                                      R Offline
                                      R Offline
                                      RossMW
                                      wrote on last edited by
                                      #18

                                      Thanks. Changed it to magenta, so now its easy to spot!

                                      1 Reply Last reply
                                      0
                                      • R RossMW

                                        Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

                                        S Offline
                                        S Offline
                                        Super Lloyd
                                        wrote on last edited by
                                        #19

                                        how about... instead of

                                        if (condition)
                                        {
                                        ....
                                        }

                                        use

                                        if (!condition)
                                        return;
                                        ....

                                        All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!

                                        J 1 Reply Last reply
                                        0
                                        • R RossMW

                                          Now, I am not interested in a VB versus C# debate but. In my job I only spend about 20% of my time coding. Being from a C# background anything new I would normally do in C# (and yes very occasionally VB), but I also have to maintain old VB code (and heaven forbid, very occasionally VB6). Normally I spent a month or two in each language (depending on the task at hand) and are happy in any camp. Changing back and forth between languages is relatively straight forward, but lately I noticed it takes me longer to get back into swing of C#. And the reason.. Well, I think its because I've got myself into bad c# typing habits from using vb. I seem to be wasting so time chasing missing / misplaced { }, forgetting semicolons case sensitivity and ()'s. Now semicolons, case and () problems are just a "Oh Bugger" moment, but as for missing / misplaced { } 's. They can be time waster. For all you pro c# developers, Do you have any tips on keeping these damn { } under control?

                                          J Offline
                                          J Offline
                                          justjoshin
                                          wrote on last edited by
                                          #20

                                          The keyboard shortcut "control }" will jump to the matching bracket if you can't immediately identify it. It will work when the cursor is either before or after an opening bracket or a closing bracket. I'd use that command every 5 minutes. very helpful when the scope of a set of brackets extends beyond the visible portion of the page.

                                          who knows what evil lurks in the hearts of men?

                                          R 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