X hits on this document

983 views

0 shares

0 downloads

0 comments

219 / 396

C# LANGUAGE SPECIFICATION

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 (§‎10.2.7.4).

10.2.7.1 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 views983
Page views983
Page last viewedFri Dec 09 03:53:53 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments