X hits on this document

858 views

0 shares

0 downloads

0 comments

207 / 396

C# LANGUAGE SPECIFICATION

namespace N2 { class A {} }

namespace N3 { using N1;

using N2;

class B: A {}// Error, A is ambiguous }

both N1 and N2 contain a member A, and because N3 imports both, referencing A in N3 is a compile-time error. In this situation, the conflict can be resolved either through qualification of references to A, or by introducing a using-alias-directive that picks a particular A. For example:

namespace N3 { using N1;

using N2;

using A = N1.A;

class B: A {}// A means N1.A }

Like a using-alias-directive, a using-namespace-directive does not contribute any new members to the underlying declaration space of the compilation unit or namespace, but rather affects only the compilation unit or namespace body in which it appears.

The namespace-name referenced by a using-namespace-directive is resolved in the same way as the namespace-or-type-name referenced by a using-alias-directive. Thus, using-namespace-directives in the same compilation unit or namespace body do not affect each other and can be written in any order.

9.4 Namespace members

A namespace-member-declaration is either a namespace-declaration (§‎9.2) or a type-declaration (§‎9.5).

namespace-member-declarations: namespace-member-declaration namespace-member-declarations   namespace-member-declaration

namespace-member-declaration: namespace-declaration type-declaration

A compilation unit or a namespace body can contain namespace-member-declarations, and such declarations contribute new members to the underlying declaration space of the containing compilation unit or namespace body.

9.5 Type declarations

A type-declaration is a class-declaration (§‎10.1), a struct-declaration (§‎11.1), an interface-declaration (§‎13.1), an enum-declaration (§‎14.1), or a delegate-declaration (§‎15.1).

194Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views858
Page views858
Page last viewedMon Dec 05 09:11:21 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments