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. global vars names

global vars names

Scheduled Pinned Locked Moved C#
tutorial
6 Posts 6 Posters 1 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
    sadas232341s
    wrote on last edited by
    #1

    Is there some kind of a rule where global variables should have "_" before their names. For example: _MyGlobalVar

    P OriginalGriffO L P R 5 Replies Last reply
    0
    • S sadas232341s

      Is there some kind of a rule where global variables should have "_" before their names. For example: _MyGlobalVar

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      No. It's just one of many different conventions that have come and gone. For a while, this was suggested as a standard by Microsoft, but they no longer recommend this.

      I'm not a stalker, I just know things. Oh by the way, you're out of milk.

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Onyx

      1 Reply Last reply
      0
      • S sadas232341s

        Is there some kind of a rule where global variables should have "_" before their names. For example: _MyGlobalVar

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

        To add to Petes' answer: there are no global variables in C# anyway. Every variable is part of a class...

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

        "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
        • S sadas232341s

          Is there some kind of a rule where global variables should have "_" before their names. For example: _MyGlobalVar

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Absolutely not, I would never do that. IMO identifier names should be easily readable and pronounceable, no special characters, no Hungarian notation. :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          1 Reply Last reply
          0
          • S sadas232341s

            Is there some kind of a rule where global variables should have "_" before their names. For example: _MyGlobalVar

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

            Contrarywise; there is a rule against global variables. But to heck with what other people call "rules"; do whatever you darn well please. Just be consistent. And if your organization has a coding standard, follow it.

            1 Reply Last reply
            0
            • S sadas232341s

              Is there some kind of a rule where global variables should have "_" before their names. For example: _MyGlobalVar

              R Offline
              R Offline
              RaviRanjanKr
              wrote on last edited by
              #6

              TCPMem wrote:

              Is there some kind of a rule where global variables should have "_" before their names

              No there is no some kind of rule where global variables should have "_". "_" is one of the symbol which can be used defining variable name. you need to only follow the standard rule made for declaring Variable Name.

              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