ECMA-334 C# Language Specification

14.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:

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).