Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C-sharp language specification.2004.pdf
Скачиваний:
14
Добавлен:
23.08.2013
Размер:
2.55 Mб
Скачать

C# LANGUAGE SPECIFICATION

1shows a class C that contains a nested class Nested. Within Nested, the method G calls the static method F

2defined in C, and F has private declared accessibility. end example]

3A nested type also can access protected members defined in a base type of its containing type. [Example: In

4the following code

5using System;

6class Base

7{

8

protected void F() {

9

Console.WriteLine("Base.F");

10}

11}

12class Derived: Base

13{

14

public class Nested

15

{

 

16

public void G() {

17

Derived d = new Derived();

18

d.F();

// ok

19

}

 

20}

21}

22class Test

23{

24

static void Main() {

25

Derived.Nested n = new Derived.Nested();

26

n.G();

27}

28}

29the nested class Derived.Nested accesses the protected method F defined in Derived's base class, Base,

30by calling through an instance of Derived. end example]

3117.2.7 Reserved member names

32To facilitate the underlying C# runtime implementation, for each source member declaration that is a

33property, event, or indexer, the implementation shall reserve two method signatures based on the kind of the

34member declaration, its name, and its type (§17.2.7.1, §17.2.7.2, §17.2.7.3). It is a compile-time error for a

35program to declare a member whose signature matches one of these reserved signatures, even if the

36underlying runtime implementation does not make use of these reservations.

37The reserved names do not introduce declarations, thus they do not participate in member lookup. However,

38a declaration’s associated reserved method signatures do participate in inheritance (§17.2.1), and can be

39hidden with the new modifier (§17.2.2).

40[Note: The reservation of these names serves three purposes:

411. To allow the underlying implementation to use an ordinary identifier as a method name for get or set

42access to the C# language feature.

432. To allow other languages to interoperate using an ordinary identifier as a method name for get or set

44access to the C# language feature.

453. To help ensure that the source accepted by one conforming compiler is accepted by another, by making

46the specifics of reserved member names consistent across all C# implementations.

47end note]

48The declaration of a destructor (§17.12) also causes a signature to be reserved (§17.2.7.4).

4917.2.7.1 Member names reserved for properties

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

268

Соседние файлы в предмете Электротехника