Thread: namespace
View Single Post
  #2 (permalink)  
Old December 21st, 2003, 11:18 AM
Ibn_Aziz Ibn_Aziz is offline
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Again answering my own questions.....

The namespace keyword is in reality used like the package keyword in JAva... basically to organise into a hierarchical structure of code....

ie

namespace ExampleOfNamespaces
{
     namespace ClassA
     {
          public ClassA
          {
                 ...
           }
     }

     namespace ClassB
     {
           public ClassB
           {
                ....
           }
      }
}


Then to be able to use class A, one would have to specify...

using ExampleOfNamespaces.ClassA;

Likewise to ab able to use class B one would have to specify

using ExampleOfNamespaces.ClassB;

One thing to bear in mind is that namepsace elements cannot explicitly be decalared as other than 'public'.

so this would cause an error....

namespace Trial
{
    private class box //error because only public allowed
    {
        ...
    }
}