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; ... |
Get C# Primer Plus 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.