What is the default NameSpace

  • Thread starter Thread starter ad
  • Start date Start date
Hi ad,
if you do not create a namespace inside a class it is included in the
global namespace and can be referenced without any name space information i.e.

namespace MyNewNameSpace
{
class Program
{
static void Main(string[] args)
{
//No namespace information required.
GlobalNameSpaceClass c1 = new GlobalNameSpaceClass();
}
}
}


//Not inside a namespace
class GlobalNameSpaceClass
{
public GlobalNameSpaceClass()
{
}
}


I wouldn't recommend doing this though as namespaces help to avoid conflicts
between identically named classes.

Hope that helps
Mark R Dawson
http://www.markdawson.org
 
Back
Top