Primary expressions include the simplest forms of expressions.
primary-expression:
array-creation-expression
primary-no-array-creation-expression
primary-no-array-creation-expression:
literal
simple-name
parenthesized-expression
member-access
invocation-expression
element-access
this-access
base-access
post-increment-expression
post-decrement-expression
object-creation-expression
delegate-creation-expression
typeof-expression
checked-expression
unchecked-expression
Primary expressions are divided between array-creation-expressions and
primary-no-array-creationexpressions.
Treating array-creation-expression in this way, rather than listing it
along with the other simple
expression forms, enables the grammar to disallow potentially confusing
code such as
C# LANGUAGE SPECIFICATION
138
object o = new int[3][1];
which would otherwise be interpreted as
object o = (new int[3])[1];
primary-expression:
array-creation-expression
primary-no-array-creation-expression
primary-no-array-creation-expression:
literal
simple-name
parenthesized-expression
member-access
invocation-expression
element-access
this-access
base-access
post-increment-expression
post-decrement-expression
object-creation-expression
delegate-creation-expression
typeof-expression
checked-expression
unchecked-expression
Primary expressions are divided between array-creation-expressions and
primary-no-array-creationexpressions.
Treating array-creation-expression in this way, rather than listing it
along with the other simple
expression forms, enables the grammar to disallow potentially confusing
code such as
C# LANGUAGE SPECIFICATION
138
object o = new int[3][1];
which would otherwise be interpreted as
object o = (new int[3])[1];
本文详细解析了C#中的基本表达式语法,包括数组创建表达式和其他非数组创建的一级表达式。通过理解这些基本概念,开发者可以避免一些常见的语法陷阱。
1381

被折叠的 条评论
为什么被折叠?



