O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declaring Namespaces

To declare a new namespace, use the namespace keyword in C#:

namespace Contoso.CashFlow.Client{    // Classes, structs, interfaces, enums, delegates, etc. can go in here}

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required