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

Importing Namespaces

In C#, the way to import namespaces is by means of the using directive. As a result, instead of having to use fully qualified type names, you can refer to types by a shorter name. Leveraging using directives simply affects the name resolution carried out by the compiler. At runtime, types are always referred to by fully qualified names, as you saw before in Figure 24.4.

The using directives are scoped to the immediately enclosing compilation unit (that is, code file) or the namespace declaration in which they’re contained. For example, given the following code, you can refer to types in the System namespace directly:

using System;namespace Contoso.CashFlow.Client{    class Program    {        static ...

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