global:: ?

  • Thread starter Thread starter sloppycode
  • Start date Start date
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?
 
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!");
}
}
 
Back
Top