Global Scope

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • george r smith

    Global Scope

    In the MSDN documentation there is a reference to "the global scope". For
    example
    "You can declare types directly in the global scope."

    I have search extensively and can not find a definition of the "global
    scope" but could it
    be the space above the namespace reserved word, such as:

    public class Bank { ... }
    namespace Banking

    Is the public class Bank in the global scope area and what purpose does this
    placement
    serve.
    thanks
    grs


  • 100

    #2
    Re: Global Scope

    Hi george,

    In C# when type is defined outside any namespace it becomes part of default
    unnamed namespace. This global namespace could be what they reference as
    *the global scope*.

    Even though C# doesn allow methods and variables to be declared outside the
    types CLR support such global methods and variables and they can be used at
    least with ILAsm. So it could be the other possible place where you could
    find *the global scope* term used. Anyway, I believe these global methods
    and variables are not CLI complaint.

    HTH
    B\rgds
    100

    "george r smith" <gsmith@budgete xt.com> wrote in message
    news:OShiXxGqDH A.1324@TK2MSFTN GP09.phx.gbl...[color=blue]
    > In the MSDN documentation there is a reference to "the global scope". For
    > example
    > "You can declare types directly in the global scope."
    >
    > I have search extensively and can not find a definition of the "global
    > scope" but could it
    > be the space above the namespace reserved word, such as:
    >
    > public class Bank { ... }
    > namespace Banking
    >
    > Is the public class Bank in the global scope area and what purpose does[/color]
    this[color=blue]
    > placement
    > serve.
    > thanks
    > grs
    >
    >[/color]


    Comment

    • Willy Denoyette [MVP]

      #3
      Re: Global Scope

      Can you please indicate at which page in MSDN there is such reference?

      Willy.

      "george r smith" <gsmith@budgete xt.com> wrote in message news:OShiXxGqDH A.1324@TK2MSFTN GP09.phx.gbl...[color=blue]
      > In the MSDN documentation there is a reference to "the global scope". For
      > example
      > "You can declare types directly in the global scope."
      >
      > I have search extensively and can not find a definition of the "global
      > scope" but could it
      > be the space above the namespace reserved word, such as:
      >
      > public class Bank { ... }
      > namespace Banking
      >
      > Is the public class Bank in the global scope area and what purpose does this
      > placement
      > serve.
      > thanks
      > grs
      >
      >[/color]


      Comment

      • george r smith

        #4
        Re: Global Scope

        I did a search with google "global scope" and c# and came up with
        Gain technical skills through documentation and training, earn certifications and connect with the community



        You will also see many mentions of the term. I have had two responses one
        says area above the namespace is global scope - the othere says between
        namespace and the first class.




        "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
        news:ehmQAOKqDH A.1740@TK2MSFTN GP12.phx.gbl...[color=blue]
        > Can you please indicate at which page in MSDN there is such reference?
        >
        > Willy.
        >
        > "george r smith" <gsmith@budgete xt.com> wrote in message[/color]
        news:OShiXxGqDH A.1324@TK2MSFTN GP09.phx.gbl...[color=blue][color=green]
        > > In the MSDN documentation there is a reference to "the global scope".[/color][/color]
        For[color=blue][color=green]
        > > example
        > > "You can declare types directly in the global scope."
        > >
        > > I have search extensively and can not find a definition of the "global
        > > scope" but could it
        > > be the space above the namespace reserved word, such as:
        > >
        > > public class Bank { ... }
        > > namespace Banking
        > >
        > > Is the public class Bank in the global scope area and what purpose does[/color][/color]
        this[color=blue][color=green]
        > > placement
        > > serve.
        > > thanks
        > > grs
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • 100

          #5
          Re: Global Scope

          Hi George,[color=blue]
          > http://msdn.microsoft.com/msdnmag/is...1/07/patterns/[/color]
          I this article you can read:
          "...
          C# doesn't allow variables at global scope anyway, but it is possible to
          create an object on the heap at the outset of a method and not use it until
          much later, if at all. The Singleton pattern offers an elegant solution in
          such cases.
          ....
          "[color=blue]
          >[/color]

          For attributes *global scope* means that they are defined for the entire
          assembly or module.


          B\rgds
          100
          [color=blue]
          >
          > You will also see many mentions of the term. I have had two responses one
          > says area above the namespace is global scope - the othere says between
          > namespace and the first class.
          >
          >
          >
          >
          > "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
          > news:ehmQAOKqDH A.1740@TK2MSFTN GP12.phx.gbl...[color=green]
          > > Can you please indicate at which page in MSDN there is such reference?
          > >
          > > Willy.
          > >
          > > "george r smith" <gsmith@budgete xt.com> wrote in message[/color]
          > news:OShiXxGqDH A.1324@TK2MSFTN GP09.phx.gbl...[color=green][color=darkred]
          > > > In the MSDN documentation there is a reference to "the global scope".[/color][/color]
          > For[color=green][color=darkred]
          > > > example
          > > > "You can declare types directly in the global scope."
          > > >
          > > > I have search extensively and can not find a definition of the "global
          > > > scope" but could it
          > > > be the space above the namespace reserved word, such as:
          > > >
          > > > public class Bank { ... }
          > > > namespace Banking
          > > >
          > > > Is the public class Bank in the global scope area and what purpose[/color][/color][/color]
          does[color=blue]
          > this[color=green][color=darkred]
          > > > placement
          > > > serve.
          > > > thanks
          > > > grs
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Willy Denoyette [MVP]

            #6
            Re: Global Scope


            "george r smith" <gsmith@budgete xt.com> wrote in message news:elJD9nTqDH A.744@tk2msftng p13.phx.gbl...[color=blue]
            > I did a search with google "global scope" and c# and came up with
            > http://msdn.microsoft.com/msdnmag/is...1/07/patterns/
            > http://msdn.microsoft.com/library/de...pspec_17_2.asp
            >
            > You will also see many mentions of the term. I have had two responses one
            > says area above the namespace is global scope - the othere says between
            > namespace and the first class.[/color]

            George,
            Please read both articles carefully.
            [1]<Article snip> A variable declared at global scope will be created on startup regardless of whether it is needed—it may very well
            be that the object isn't always needed. C# doesn't allow variables at global scope anyway, but it is possible to create an object on
            the heap at the outset of a method and not use it until much later, if at all. The Singleton pattern offers an elegant solution in
            such cases.

            [2] Is talking about attributes, nowhere is stated that "types can have global scope"

            The current version of C# doesn't allow globally scoped types (you'll have to wait for the next version).
            Willy.


            Comment

            Working...