Syntax Question (::)

M

Mac McMicMac

I was just going through Resources.Designer.cs and saw this code:

internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;


What is the meaning of the two colons between 'global' and 'System' in the
second line? (... global::System.Resources...)

I understand a single colon as indicating inheritance in a class
declaration... but what about two colons in a variable declaration?

Thanks.
 
P

pvdg42

Mac McMicMac said:
I was just going through Resources.Designer.cs and saw this code:

internal class Resources {
private static global::System.Resources.ResourceManager
resourceMan;


What is the meaning of the two colons between 'global' and 'System' in the
second line? (... global::System.Resources...)

I understand a single colon as indicating inheritance in a class
declaration... but what about two colons in a variable declaration?

Thanks.

Here you go...

http://msdn2.microsoft.com/en-us/library/htccxtad(VS.80).aspx
 
A

Alun Harford

Mac said:
I was just going through Resources.Designer.cs and saw this code:

internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;


What is the meaning of the two colons between 'global' and 'System' in the
second line? (... global::System.Resources...)

I understand a single colon as indicating inheritance in a class
declaration... but what about two colons in a variable declaration?

Consider the situation where you have two different types with the same
name and namespace, located in two different dlls. You need to be able
to define which of those types you want to refer to.
If you use a compiler flag when you include the dll, you can give a dll
an alias (the default is 'global').

Then you can use alias::type to refer to that type.

Alun Harford
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top