ECMA-334 C# Language Specification14.5.6.2: Indexer access |
For an indexer access, the primary-no-array-creation-expression
of the element-accessmust be a variable or value of a class, struct, or interface type, and this type must implement one or more indexers that are applicable with respect to the expression-list
of the element-access
.
The compile-time processing of an indexer access of the form P[A], where P is a primary-no-array-creation-expression
of a class, struct, or interface type T, and A is an expression-list
, consists of the following steps:
expression-list
are evaluated in order, from left to right. The result of processing the indexer access is an expression classified as an indexer access. The indexer access expression references the indexer determined in the step above, and has an associated instance expression of P and an associated argument list of A. Depending on the context in which it is used, an indexer access causes invocation of either the get-accessor or the set-accessor of the indexer. If the indexer access is the target of an assignment, the set-accessor is invoked to assign a new value (14.13.1). In all other cases, the get-accessor is invoked to obtain the current value (14.1.1).