X hits on this document





219 / 396


class Test { static void Main() { Derived.Nested n = new Derived.Nested(); n.G(); } }

the nested class Derived.Nested accesses the protected method F defined in Derived’s base class, Base, by calling through an instance of Derived.

10.2.7 Reserved member names

To facilitate the underlying C# runtime implementation, for each source member declaration that is a property, event, or indexer, the implementation must reserve two method signatures based on the kind of the member declaration, its name, and its type. It is a compile-time error for a program to declare a member whose signature matches one of these reserved signatures, even if the underlying runtime implementation does not make use of these reservations.

The reserved names do not introduce declarations, thus they do not participate in member lookup. However, a declaration’s associated reserved method signatures do participate in inheritance (§‎10.2.1), and can be hidden with the new modifier (§‎10.2.2).

The reservation of these names serves three purposes:

To allow the underlying implementation to use an ordinary identifier as a method name for get or set access to the C# language feature.

To allow other languages to interoperate using an ordinary identifier as a method name for get or set access to the C# language feature.

To help ensure that the source accepted by one conforming compiler is accepted by another, by making the specifics of reserved member names consistent across all C# implementations.

The declaration of a destructor (§‎10.12) also causes a signature to be reserved (§‎ Member names reserved for properties

For a property P (§‎10.6) of type T, the following signatures are reserved:

T get_P(); void set_P(T value);

Both signatures are reserved, even if the property is read-only or write-only.

In the example

using System;

class A { public int P { get { return 123; } } }

class B: A { new public int get_P() { return 456; }

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

Document info
Document views1204
Page views1204
Page last viewedThu Jan 19 00:22:43 UTC 2017