13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 10 Basic conceptsclass Derived: Base{new public void F() {}}The new modifier indicates that the F in Derived is “new”, and that it is indeed intended to hide theinherited member. end example]A declaration of a new member hides an inherited member only within the scope of the new member.[Example:class Base{public static void F() {}}class Derived: Base{new private static void F() {} // Hides Base.F in Derived only}class MoreDerived: Derived{static void G() { F(); } // Invokes Base.F}In the example above, the declaration of F in Derived hides the F that was inherited from Base, but sincethe new F in Derived has private access, its scope does not extend to MoreDerived. Thus, the call F() inMoreDerived.G is valid and will invoke Base.F. end example]10.8 Namespace and type namesSeveral contexts in a <strong>C#</strong> program require a namespace-name or a type-name to be specified. Either form ofname is written as one or more identifiers separated by “.” tokens.namespace-name:namespace-or-type-nametype-name:namespace-or-type-namenamespace-or-type-name:identifiernamespace-or-type-name . identifierA type-name is a namespace-or-type-name that refers to a type. Following resolution as described below, thenamespace-or-type-name of a type-name must refer to a type, or otherwise a compile-time error occurs.A namespace-name is a namespace-or-type-name that refers to a namespace. Following resolution asdescribed below, the namespace-or-type-name of a namespace-name must refer to a namespace, orotherwise a compile-time error occurs.The meaning of a namespace-or-type-name is determined as follows:• If the namespace-or-type-name consists of a single identifier:If the namespace-or-type-name appears within the body of a class or struct declaration, then starting withthat class or struct declaration and continuing with each enclosing class or struct declaration (if any), if amember with the given name exists, is accessible, and denotes a type, then the namespace-or-type-namerefers to that member. Non-type members (constants, fields, methods, properties, indexers, operators,instance constructors, destructors, and static constructors) are ignored when determining the meaning of anamespace-or-type-name.Otherwise, starting with the namespace in which the namespace-or-type-name occurs, continuing with eachenclosing namespace (if any), and ending with the global namespace, the following steps are evaluated untilan entity is located:83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!