O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

Namespaces and Compilation Units

Listing 15.2 shows the most important code fragments for defining two namespaces called ElevatorSimulation (spanning lines 3–61 and containing the Elevator, Person, and Building classes) and BankSimulation (in lines 63–101 and containing the Account, Bank, and Building classes). The two namespaces are positioned beside each other in the same compilation unit. The class MyGlobalNamespaceClass (lines 103–120) has been thrown in to demonstrate a class that exists beside two namespaces and outside any namespace. The latter fact, as discussed in the previous section, causes it to belong to the global nameless namespace.

Listing 15.2. Two Namespaces Written Beside Each Other in a Compilation Unit
 001: using System; ...

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