Namespaces and Class Libraries
Explore how namespaces help organize your C# classes and prevent naming conflicts while mastering the use of class libraries to promote code reuse. This lesson helps you understand importing namespaces, nested namespaces, and leveraging class libraries for building efficient applications.
We'll cover the following...
We'll cover the following...
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 ...