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

C# LANGUAGE SPECIFICATION

112.1.2.2 Instance variables in structs

2An instance variable of a struct has exactly the same lifetime as the struct variable to which it belongs. In

3other words, when a variable of a struct type comes into existence or ceases to exist, so too do the instance

4variables of the struct.

5The initial assignment state of an instance variable of a struct is the same as that of the containing struct

6variable. In other words, when a struct variable is considered initially assigned, so too are its instance

7variables, and when a struct variable is considered initially unassigned, its instance variables are likewise

8unassigned.

912.1.3 Array elements

10The elements of an array come into existence when an array instance is created, and cease to exist when

11there are no references to that array instance.

12The initial value of each of the elements of an array is the default value (§12.2) of the type of the array

13elements.

14For the purpose of definite assignment checking, an array element is considered initially assigned.

1512.1.4 Value parameters

16A parameter declared without a ref or out modifier is a value parameter.

17A value parameter comes into existence upon invocation of the function member (method, instance

18constructor, accessor, or operator) to which the parameter belongs, and is initialized with the value of the

19argument given in the invocation. A value parameter ceases to exist upon return of the function member

20(except when the value parameter is captured by an anonymous method (§14.5.14.3.1) or the function

21member body is an iterator block (§27)).

22For the purpose of definite assignment checking, a value parameter is considered initially assigned.

2312.1.5 Reference parameters

24A parameter declared with a ref modifier is a reference parameter.

25A reference parameter does not create a new storage location. Instead, a reference parameter represents the

26same storage location as the variable given as the argument in the function member invocation. Thus, the

27value of a reference parameter is always the same as the underlying variable.

28The following definite assignment rules apply to reference parameters. [Note: The rules for output

29parameters are different, and are described in §12.1.6. end note]

30A variable shall be definitely assigned (§12.3) before it can be passed as a reference parameter in a

31function member invocation.

32Within a function member, a reference parameter is considered initially assigned.

33Within an instance method or instance accessor of a struct type, the this keyword behaves exactly as a

34reference parameter of the struct type (§14.5.7).

3512.1.6 Output parameters

36A parameter declared with an out modifier is an output parameter.

37An output parameter does not create a new storage location. Instead, an output parameter represents the

38same storage location as the variable given as the argument in the function member invocation. Thus, the

39value of an output parameter is always the same as the underlying variable.

40The following definite assignment rules apply to output parameters. [Note: The rules for reference

41parameters are different, and are described in §12.1.5. end note]

116

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