The use of namespace hierarchies : Namespace : Language Basics C# Examples


C# Examples » Language Basics » Namespace »

 

The use of namespace hierarchies









    
namespace  CompanyName
{
    namespace  UserInterface    //  nested  namespace
    {
        public  class  MyClass
        {
            public  void  Test()
            {
                System.Console.WriteLine("UserInterface  Test()");
            }
        }
    }
}


namespace  CompanyName.DatabaseAccess    //  nested  namespace  using  dot
{
    public  class  MyClass
    {
        public  void  Test()
        {
            System.Console.WriteLine("DatabaseAccess  Test()");
        }
    }
}


class  MainClass  {

    public  static  void  Main()  {
        CompanyName.UserInterface.MyClass  myUI  =  new  CompanyName.UserInterface.MyClass();
        CompanyName.DatabaseAccess.MyClass  myDB  =  new  CompanyName.DatabaseAccess.MyClass();

        CompanyName.DatabaseAccess.MyClass  myMT  =  new  CompanyName.DatabaseAccess.MyClass();

        myUI.Test();
        myDB.Test();
        myMT.Test();
    }
}
    
   
  
   



Output

UserInterface Test()
DatabaseAccess Test()
DatabaseAccess Test()


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Namespace