13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C#</strong> LANGUAGE SPECIFICATION• The value of each expression in the expression-list is checked against the actual bounds of eachdimension of the array instance referenced by P. If one or more values are out of range, aSystem.IndexOutOfRangeException is thrown and no further steps are executed.• The location of the array element given by the index expression(s) is computed, and this locationbecomes the result of the array access.14.5.6.2 Indexer accessFor an indexer access, the primary-no-array-creation-expression of the element-access must be a variableor value of a class, struct, or interface type, and this type must implement one or more indexers that areapplicable 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-arraycreation-expressionof a class, struct, or interface type T, and A is an expression-list, consists of thefollowing steps:• The set of indexers provided by T is constructed. The set consists of all indexers declared in T or a basetype of T that are not override declarations and are accessible in the current context (§10.5).• The set is reduced to those indexers that are applicable and not hidden by other indexers. The followingrules are applied to each indexer S.I in the set, where S is the type in which the indexer I is declared:If I is not applicable with respect to A (§14.4.2.1), then I is removed from the set.If I is applicable with respect to A (§14.4.2.1), then all indexers declared in a base type of S are removedfrom the set.• If the resulting set of candidate indexers is empty, then no applicable indexers exist, and a compile-timeerror occurs. If the candidate indexers are not all declared in the same type, the indexer access isambiguous, and a compile-time error occurs (this latter situation can only occur for an indexer access onan instance of an interface that has multiple direct base interfaces).• The best indexer of the set of candidate indexers is identified using the overload resolution rules of§14.4.2. If a single best indexer cannot be identified, the indexer access is ambiguous, and a compiletimeerror occurs.• The index expressions of the expression-list are evaluated in order, from left to right. The result ofprocessing the indexer access is an expression classified as an indexer access. The indexer accessexpression references the indexer determined in the step above, and has an associated instanceexpression 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-accessoror the set-accessor of the indexer. If the indexer access is the target of an assignment, the set-accessor isinvoked to assign a new value (§14.13.1). In all other cases, the get-accessor is invoked to obtain the currentvalue (§14.1.1).14.5.7 This accessA this-access consists of the reserved word this.this-access:thisA this-access is permitted only in the block of an instance constructor, an instance method, or an instanceaccessor. It has one of the following meanings:• When this is used in a primary-expression within an instance constructor of a class, it is classified as avalue. The type of the value is the class within which the usage occurs, and the value is a reference to theobject being constructed.144

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!