Namespaces can be nested : Namespace : Language Basics C# Examples


C# Examples » Language Basics » Namespace »

 

Namespaces can be nested









    
using  System;  
  
namespace  NS1  {  
    class  ClassA  {  
          public  ClassA()  {  
              Console.WriteLine("constructing  ClassA");  
        }  
    }  
    namespace  NS2  {  //  a  nested  namespace  
        class  ClassB  {  
              public  ClassB()  {  
                  Console.WriteLine("constructing  ClassB");  
            }  
        }  
    }  
}  
  
class  MainClass  {  
    public  static  void  Main()  {  
        NS1.ClassA  a  =  new  NS1.ClassA();  
  
        NS1.NS2.ClassB  b  =  new  NS1.NS2.ClassB();
    }  
}
    
   
  
   



Output

constructing ClassA
constructing ClassB


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Namespace