Declaring Namespaces
To declare a new namespace, use the namespace
keyword in C#:
The default namespace chosen for new code files in a Visual Studio project is based on a setting specified for the project. This setting, shown in Figure 24.5, gets its default value from the name of the project upon creation. The output assembly name follows this default inferred value, too. It’s considered good practice to reflect the top-level namespace for types defined in an assembly in the assembly’s name. For example, the System.Web
assembly (mostly) contains System.Web
functionality.
Figure 24.5. Default namespace configuration setting.
Namespaces can ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.