473,396 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Nov 15 '05 #1
5 3561
100
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" <gs****@budgetext.com> wrote in message
news:OS**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #2
Can you please indicate at which page in MSDN there is such reference?

Willy.

"george r smith" <gs****@budgetext.com> wrote in message news:OS**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #3
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.


"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
Can you please indicate at which page in MSDN there is such reference?

Willy.

"george r smith" <gs****@budgetext.com> wrote in message

news:OS**************@TK2MSFTNGP09.phx.gbl...
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


Nov 15 '05 #4
100
Hi George,
http://msdn.microsoft.com/msdnmag/is...1/07/patterns/ 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.
....
" http://msdn.microsoft.com/library/de...pspec_17_2.asp
For attributes *global scope* means that they are defined for the entire
assembly or module.
B\rgds
100

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]" <wi*************@pandora.be> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
Can you please indicate at which page in MSDN there is such reference?

Willy.

"george r smith" <gs****@budgetext.com> wrote in message news:OS**************@TK2MSFTNGP09.phx.gbl...
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



Nov 15 '05 #5

"george r smith" <gs****@budgetext.com> wrote in message news:el*************@tk2msftngp13.phx.gbl...
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.


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.
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Yoyoma_2 | last post by:
Hello, i'me having a wierd problems with sessions. PHP 4.3.3, Register globals is on, and the sessions module is installed. if i have a page like this: <? session_start(); $_SESSION="blue";...
5
by: NotGiven | last post by:
I have an file I call using: require_once() In this file I have variables I'd like to use in the calling page and functions called by that page. How can I do this? example:
2
by: Wat | last post by:
If a class is not given a namespace, what does this imply? From inside of the class, if to call global functions, should global scope :: be used at all? If global scope :: used, what benefits...
1
by: Robert North | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've just started programming JS, and one question keeps nagging me: I can insert a <script> element anywhere in HTML, and when it's executed...
10
by: a.farhadi | last post by:
hi guys, I want to eval some javascript code at a function. and my code contains some variable and function definitions. my problem is that the code is evaluated in function scope not global...
1
by: Maziar Aflatoun | last post by:
Hi everyone, I'm having a problem with reading user groups on Active Directory using C#. It returns all the groups in the Universal scope for a specific user. However, I only need the groups in...
10
by: m.epper | last post by:
Hi to everybody. First of all sorry for my english, I'm italian. How can I execute a portion of code, in a function, into the global scope? Example: <?php
3
by: VRSki | last post by:
Hello, Is there any way to use "using" for aliasing in the global scope? The example below works fine in the context of a given file, but in the different file MyByte alias is unknown. Is...
27
by: Erwin Moller | last post by:
Hi group, Consider this simple script (tested on FF3): <script type="text/javascript"> test = 'outer'; for (var i=0;i<2;i++){ alert(test); var test = 'inner'; alert (test);
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.