A Namespace is used to organize classes. Example of in-built .Net Namespace is the System Namespace.
• One can create his own Namespace and define the scope of the classes belonging to the Namespace.
• Keyword using is used in order to access a class belonging to a particular Namespace.
• A class belonging to a Namespace can be accessed only when the Namespace with the help of using directive.
• A namespace does not have any access modifiers i.e. namespace cannot be public, private, etc.
• A namespace can belong to multiple assemblies and also a single assembly can have multiple namespaces.
Example:
namespace MySpace
{
public class A
{
public static void Fun()
{
}
}
}namespace YourSpace{
//Accesing the Namespace
using MySpace;
public class B
{
public void Fun()
{
A.Fun();
}
}
}