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

Chapter 14 Expressions

114. Expressions

2An expression is a sequence of operators and operands. This clause defines the syntax, order of evaluation of

3operands and operators, and meaning of expressions.

414.1 Expression classifications

5An expression is classified as one of the following:

6A value. Every value has an associated type.

7A variable. Every variable has an associated type, namely the declared type of the variable.

8A namespace. An expression with this classification can only appear as the left-hand side of a member-

9access (§14.5.4). In any other context, an expression classified as a namespace causes a compile-time

10error.

11A type. An expression with this classification can only appear as the left-hand side of a member-access

12(§14.5.4), or as an operand for the as operator (§14.9.10), the is operator (§14.9.9), or the typeof

13operator (§14.5.11). In any other context, an expression classified as a type causes a compile-time error.

14A method group, which is a set of overloaded methods resulting from a member lookup (§14.3). A

15method group can have an associated instance expression. When an instance method is invoked, the

16result of evaluating the instance expression becomes the instance represented by this (§14.5.7). A

17method group can be used in an invocation-expression (§14.5.5), used in a delegate-creation-expression

18(§14.5.10.3), or implicitly converted to a compatible delegate type. In any other context, an expression

19classified as a method group causes a compile-time error.

20An anonymous method. An expression with this classification can be used in a delegate-creation-

21expression (§14.5.10.3) or implicitly converted to a compatible delegate type. In any other context, an

22expression classified as an anonymous method causes a compile-time error.

23A property access. Every property access has an associated type, namely the type of the property.

24Furthermore, a property access can have an associated instance expression. When an accessor (the get

25or set block) of an instance property access is invoked, the result of evaluating the instance expression

26becomes the instance represented by this (§14.5.7).

27An event access. Every event access has an associated type, namely the type of the event. Furthermore,

28an event access can have an associated instance expression. An event access can appear as the left-hand

29operand of the += and -= operators (§14.13.3). In any other context, an expression classified as an event

30access causes a compile-time error.

31An indexer access. Every indexer access has an associated type, namely the element type of the indexer.

32Furthermore, an indexer access has an associated instance expression and an associated argument list.

33When an accessor (the get or set block) of an indexer access is invoked, the result of evaluating the

34instance expression becomes the instance represented by this (§14.5.7), and the result of evaluating the

35argument list becomes the parameter list of the invocation.

36Nothing. This occurs when the expression is an invocation of a method with a return type of void. An

37expression classified as nothing is only valid in the context of a statement-expression (§15.6).

38The final result of an expression is never a namespace, type, method group, anonymous method, or event

39access. Rather, as noted above, these categories of expressions are intermediate constructs that are only

40permitted in certain contexts.

145

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