13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14 Expressions• If the compile-time type of E is an interface, the function member to invoke is theimplementation of M provided by the run-time type of the instance referenced by E. Thisfunction member is determined by applying the interface mapping rules (§20.4.2) to determinethe implementation of M provided by the run-time type of the instance referenced by E.• Otherwise, if M is a virtual function member, the function member to invoke is theimplementation of M provided by the run-time type of the instance referenced by E. Thisfunction member is determined by applying the rules for determining the most derivedimplementation (§17.5.3) of M with respect to the run-time type of the instance referenced by E.• Otherwise, M is a non-virtual function member, and the function member to invoke is M itself.The function member implementation determined in the step above is invoked. The object referenced by Ebecomes the object referenced by this.14.4.3.1 Invocations on boxed instancesA function member implemented in a value-type can be invoked through a boxed instance of that value-typein the following situations:• When the function member is an override of a method inherited from type object and is invokedthrough an instance expression of type object.• When the function member is an implementation of an interface function member and is invokedthrough an instance expression of an interface-type.• When the function member is invoked through a delegate.In these situations, the boxed instance is considered to contain a variable of the value-type, and this variablebecomes the variable referenced by this within the function member invocation. [Note: In particular, thismeans that when a function member is invoked on a boxed instance, it is possible for the function member tomodify the value contained in the boxed instance. end note]14.5 Primary expressionsPrimary expressions include the simplest forms of expressions.primary-expression:array-creation-expressionprimary-no-array-creation-expressionprimary-no-array-creation-expression:literalsimple-nameparenthesized-expressionmember-accessinvocation-expressionelement-accessthis-accessbase-accesspost-increment-expressionpost-decrement-expressionobject-creation-expressiondelegate-creation-expressiontypeof-expressionchecked-expressionunchecked-expressionPrimary 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 simpleexpression forms, enables the grammar to disallow potentially confusing code such as137

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

Saved successfully!

Ooh no, something went wrong!