От: | nikov | http://www.linkedin.com/in/nikov | |
Дата: | 13.10.06 07:04 | ||
Оценка: |
class Stuff
{
const int x = new int();
}
7.15 Constant expressions
..................
. The following constructs are permitted in constant expressions:
· Literals (including the null literal).
· References to const members of class and struct types.
· References to members of enumeration types.
· Parenthesized sub-expressions, which are themselves constant expressions.
· Cast expressions, provided the target type is one of the types listed above.
· The predefined +, –, !, and ~ unary operators.
· The predefined +, –, *, /, %, <<, >>, &, |, ^, &&, ||, ==, !=, <, >, <=, and >= binary operators, provided each operand is of a type listed above.
· The ?: conditional operator.
The following conversions are permitted in constant expressions:
· Identity conversions
· Numeric conversions
· Enumeration conversions
· Constant expression conversions
· Implicit and explicit reference conversions, provided that the source of the conversions is a constant expression that evaluates to the null value.
Other conversions including boxing, unboxing and implicit reference conversions of non-null values are not permitted in constant expressions.