...

/

Namespaces and Class Libraries

Namespaces and Class Libraries

Learn about namespaces and their role when creating class libraries.

Namespaces

All user-defined classes and structures, as a rule, don’t exist in a vacuum, but are enclosed in special containers called namespaces. The Program class generated by default upon the creation of a new .NET project already resides in a namespace. The name of this namespace is usually the same as the name of the project:

namespace MyFirstProject
{
	class Program
	{
		static void Main(string[] args)
		{
		}
	}
}

Defining a namespace

A namespace is defined using the namespace keyword, followed by the name. In the example above, the full name of the Program class is ...