More About the using Directive

As you know, the using keyword, followed by a suitable namespace name, allows us to abbreviate a class's long fully-qualified name when we refer to it in the source code. Consequently, if we were to use the classes from the two namespaces Sams.CSharpPrimerPlus.ElevatorSimulation and Sams.CSharpPrimerPlus.BankSimulation (defined in Listing 15.3) in the source code of Figure 15.1, we could use the short classnames of the classes belonging to these namespaces by including lines 1 and 2 shown in Figure 15.1.

Figure 15.1. The compiler cannot know to which namespace Building belongs.

But what if both namespaces referenced ...

Get C# Primer Plus now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.