logo
Учебник_ПОА

Namespaces

Namespaces are a way of organizing the various types that occur in a C# program. It is somewhat similar in concept to a folder in a computer file system. Like folders, namespaces enable classes to have a unique fully-qualified name. A C# program contains one or more namespaces, and each namespace is either defined by you the programmer, or defined as part of a previously written class library.

For example, the namespace System includes the Console class, a class that contains methods for reading and writing to the console window. The System namespace also contains a number of other namespaces, such as System.IO and System.Collections. The .NET Framework alone has more than eighty namespaces, each with up to thousands of classes: namespaces are used to minimize the confusion that might be caused between similarly named types and methods.

If you write a class outside of a namespace declaration, the compiler will supply a default namespace for that class.