473,772 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3581
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****@budgete xt.com> wrote in message
news:OS******** ******@TK2MSFTN GP09.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****@budgete xt.com> wrote in message news:OS******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP12.phx.gbl...
Can you please indicate at which page in MSDN there is such reference?

Willy.

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

news:OS******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP12.phx.gbl...
Can you please indicate at which page in MSDN there is such reference?

Willy.

"george r smith" <gs****@budgete xt.com> wrote in message news:OS******** ******@TK2MSFTN GP09.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****@budgete xt.com> wrote in message news:el******** *****@tk2msftng p13.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
5397
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"; ?> On the next page i can see that $_SESSION is actually equal to
5
2919
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
1949
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 does it bring? Thanks in advance!
1
1455
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 some DOM objects are created, and placed in the global scope of the script object. But which ones are placed in the global scope?
10
2401
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 scope and definations are not available in the global scope.
1
2972
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 Global scope and Domain local scope. Does anyone know I can modify the following code to this? DirectoryEntry entry = new DirectoryEntry("LDAP://" + Domain, CurrentUser, pwd, AuthenticationTypes.Secure); DirectorySearcher mySearcher = new...
10
3900
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
12344
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 there any way to extend its visibility to multiple files without redefining it? using MyByte=System.Byte;
27
1699
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
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.