Abstract
Namespaces are used both as an “internal” organization system for a program, and as an “external” organization system—a way of presenting program elements that are exposed to other programs. C# programs are organized using namespaces. Using directives are provided in this chapter to facilitate the use of namespaces. A C# program consists of one or more compilation units, each contained in a separate source file. When a C# program is compiled, all of the compilation units are processed together. Thus, compilation units can depend on each other, possibly in a circular fashion. A compilation unit defines the overall structure of a source file. A compilation unit consists of zero or more extern-alias-directives followed by zero or more using-directives followed by zero or more global-attributes followed by zero or more namespace-member-declarations. An extern-alias-directive introduces an identifier that serves as an alias for an externally defined namespace. The specification of the aliased namespace is external to the source code of the program. A namespace-declaration consists of the keyword namespace, followed by a namespace name and body, optionally followed by a semicolon. On the other hand, using directives facilitate the use of namespaces and types defined in other namespaces. Using directives impact the name resolution process of namespace-or-type-names and simple-names, but unlike declarations, using-directives do not contribute new members to the underlying declaration spaces of the compilation units or namespaces within which they are used.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.