`
talin2010
  • 浏览: 520716 次
  • 性别: Icon_minigender_1
  • 来自: 河北
社区版块
存档分类
最新评论

16.2 Namespace declarations

阅读更多
A namespace-declaration consists of the keyword namespace, followed by a
namespace name and body,
optionally followed by a semicolon.
namespace-declaration:
namespace qualified-identifier namespace-body ;opt
qualified-identifier:
identifier
qualified-identifier . identifier
namespace-body:
{ using-directivesopt namespace-member-declarationsopt }
C# LANGUAGE SPECIFICATION
202
A namespace-declaration may occur as a top-level declaration in a
compilation-unit or as a member
declaration within another namespace-declaration. When a
namespace-declaration occurs as a top-level
declaration in a compilation-unit, the namespace becomes a member of the
global namespace. When a
namespace-declaration occurs within another namespace-declaration, the
inner namespace becomes a
member of the outer namespace. In either case, the name of a namespace must
be unique within the
containing namespace.
Namespaces are implicitly public and the declaration of a namespace cannot
include any access modifiers.
Within a namespace-body, the optional using-directives import the names of
other namespaces and types,
allowing them to be referenced directly instead of through qualified names.
The optional namespacemember-
declarations contribute members to the declaration space of the namespace.
Note that all usingdirectives
must appear before any member declarations.
The qualified-identifier of a namespace-declaration may be a single
identifier or a sequence of identifiers
separated by ?.? tokens. The latter form permits a program to define a
nested namespace without lexically
nesting several namespace declarations. [Example: For example,
namespace N1.N2
{
class A {}
class B {}
}
is semantically equivalent to
namespace N1
{
namespace N2
{
class A {}
class B {}
}
}
end example]
Namespaces are open-ended, and two namespace declarations with the same
fully qualified name contribute
to the same declaration space (§10.3). [Example: In the example
namespace N1.N2
{
class A {}
}
namespace N1.N2
{
class B {}
}
the two namespace declarations above contribute to the same declaration
space, in this case declaring two
classes with the fully qualified names N1.N2.A and N1.N2.B. Because the two
declarations contribute to
the same declaration space, it would have been an error if each contained a
declaration of a member with the
same name. end example]
Namespaces whose names begin with System. are reserved for use by the
Standard Library (§D).
分享到:
评论

相关推荐

    Flex4 Declarations in ActionScript

    《Flex4声明式编程在ActionScript中的应用探析》 Flex4是Adobe Flex框架的一个重要版本,它引入了全新的ActionScript编程模型,显著提升了开发效率和应用程序的表现力。本篇文章将深入探讨Flex4中的一项核心特性...

    解决C++全局变量只能初始化不能赋值的问题

    using namespace std; int a; a = 2; int main() { return 0; } 错误提示是: C++ requires a type specifier for all declarations 声明、初始化与赋值的区别: 声明:int a; 初始化:int a = 2;(在声明的时候顺...

    Placing const in Declarations by Dan Saks

    "Placing const in Declarations by Dan Saks"这篇文章很可能是深入探讨了如何在声明中有效地使用`const`。 1. `const`的基本概念: - `const`关键字用来定义一个只读变量,一旦赋值后就不能再次更改。 - 它可以...

    css-declarations:解析和字符串化CSS声明

    : npm install css-declarations用import { parse , stringify } from 'css-declarations'var values = parse ( ` color:/*red*/purple; -webkit-border-radius: 3px !important;;` )// => {color: 'purple', ...

    关于IDEA中的.VUE文件报错 Export declarations are not supported by current JavaScript version

    IDEA中的.VUE文件报错 Export declarations are not supported by current JavaScript version 和Export declarations are not supported by current JavaScript version报错都是一个解决办法 js文件报错 第一步,...

    Addison.Wesley.C.Plus.Plus.Coding.Standards.101.Rules.Guidelines.and.Best.Practices.Oct.2004.eBoo.chm

    Why shouldn't you write namespace declarations or directives in a header file? Why should you use STL vector and string instead of arrays? How do you choose the right STL search or sort algorithm? ...

    C#基础的语法讲解,很详细

    一个编译单元通常对应一个`.cs`文件,它可以包含多个using指令、全局属性(Global Attributes)和命名空间成员声明(Namespace Member Declarations)。 编译单元的结构如下: ```csharp using-directivesopt ...

    declarations.com.ua:我们的项目会数字化并打开所有乌克兰官员的声明

    clarifications.com.ua有用的链接设计: : 将扫描的声明数字化的表格: : 我们的众包框架将用于众包数字化流程: : 各种脚本来清理数据: : R生成分析的先决条件首先安装R 3.1或更高版本然后运行R并安装以下软件包...

    YANG模型与OpenDaylight南北向接口

    YANG 模型的主要内容包括 Configuration&Operational data declarations 和 Action(RPC)&Notification declarations 对应了 YANG 模型定义中的“NETCONF 协议、NETCONF 远端过程调用(RPCs)、和 NETCONF 通知...

    Oracle数据库开发实用教程第7章.ppt

    其中,`package_name` 是包名,`public_variable_declarations` 是公共变量声明,`public_type_declarations` 是公共类型声明,`public_exception_declarations` 是公共异常声明,`function_declarations` 是函数...

    e-declarations:Liga.net杂志的d3数据可视化

    本项目“e-declarations”是Liga.net杂志的一个实例,展示了如何运用d3.js来呈现电子声明相关的数据。通过使用HTML作为基础结构,项目可能包含以下方面: 1. **数据加载与处理**:d3.js提供了方便的数据加载功能,...

    Oracle数据库开发实用教程第7章.pptx

    public_type_declarations是公共类型声明public_exception_declarations是公共异常声明。function_declarations是函数声明。procedure_specifications是过程声明。 7.1.2 包体 包体用于实现包头所定义的过程和函数...

    European Parliament - Questions and Declarations-数据集

    议会问题是欧洲议会议员向其他欧盟机构和机构提出的问题。它们是议会对其他欧盟机构和机构的直接审查形式...file/opensearch/documents/93180/european-parliament-lists-of-questions-and-declarations_metadata.json

    DBGrid3D (增加了鼠标滚轮的支持)

    { Private declarations } protected { Protected declarations } public { Public declarations } published function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): ...

    edecl:Declarations.com.ua的API包装器

    职能download_declarations()-下载声明step_to_df()-将声明列表中的部分转换为方便的表格格式,以进行数据处理。 get_corrected()-从列表声明中排除已被更正的替换的声明dintersect()-与两个声明集(两个...

    Screeps-Typescript-Declarations:* Screeps的TypeScript类型定义的存储库

    " screeps " : " github:screepers/Screeps-Typescript-Declarations/dist/screeps.d.ts " } } 用法 注意:使用此API时,您无法按照Screeps教程中建议的方式来访问小兵: Game.creeps.Worker1 // This is not ...

    Google C++ Style Guide_英文版.pdf

    - **Forward Declarations:** When possible, use forward declarations to reduce header dependencies and improve compile times. - **Inline Functions:** Inline functions can be defined in header files if ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Tabs Function Declarations and Definitions Function Calls Conditionals Loops and Switch Statements Pointer and Reference Expressions Boolean Expressions Return Values Variable and Array Initialization...

Global site tag (gtag.js) - Google Analytics