global:: ?

S

sloppycode

Have I been missing a keyword in C# for the past few years, is it new
to beta 2.0, or is it a bug in vs.net 2005 beta1? You type in global::
and get a load of namespaces? My first guess would be that it's a bug
with the intellisense, using c++ intellisense by accident..

For example
throw new global::System.NotImplementedException();

Any ideas?
 
P

Peter Jausovec

Hi,

No, it isn't a bug. It's a global namespace qualifier which indicates the
compiler to start the search at global scope. Example:

namespace Examples
{
class MyClass
{
public void MyMethod ()
{
::MyClass obj = new ::MyClass ();
obj.MyMethod ();
}
}
}

public class MyClass
{
public void MyMethod ()
{
Trace.WriteLine ("Hello!");
}
}
 

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