Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specification


14 Expressions
14.4 Function members
14.4.3 Function member invocation
Paragraph 11 This section describes the process that takes place at run-time to invoke a particular function member. 2 It is assumed that a compile-time process has already determined the particular member to invoke, possibly by applying overload resolution to a set of candidate function members.
Paragraph 21 For purposes of describing the invocation process, function members are divided into two categories: - 2 Static function members. 3 These are static methods, instance constructors, static property accessors, and user-defined operators. 4 Static function members are always non-virtual.
- 5 Instance function members. 6 These are instance methods, instance property accessors, and indexer accessors. 7 Instance function members are either non-virtual or virtual, and are always invoked on a particular instance. 8 The instance is computed by an instance expression, and it becomes accessible within the function member as this (§14.5.7).
Paragraph 31 The run-time processing of a function member invocation consists of the following steps, where M is the function member and, if M is an instance member, E is the instance expression: - 2 If M is a static function member:
- 3 The argument list is evaluated as described in §14.4.1.
- 4 M is invoked.
- 5 If M is an instance function member declared in a value-type:
- 6 E is evaluated. 7 If this evaluation causes an exception, then no further steps are executed.
- 8 If E is not classified as a variable, then a temporary local variable of E's type is created and the value of E is assigned to that variable. 9 E is then reclassified as a reference to that temporary local variable. 10 The temporary variable is accessible as this within M, but not in any other way. 11 Thus, only when E is a true variable is it possible for the caller to observe the changes that M makes to this.
- 12 The argument list is evaluated as described in §14.4.1.
- 13 M is invoked. 14 The variable referenced by E becomes the variable referenced by this.
- 15 If M is an instance function member declared in a reference-type:
- 16 E is evaluated. 17 If this evaluation causes an exception, then no further steps are executed.
- 18 The argument list is evaluated as described in §14.4.1.
- 19 If the type of E is a value-type, a boxing conversion (§11.3.1) is performed to convert E to type object, and E is considered to be of type object in the following steps. [Note: In this case, M could only be a member of System.Object. end note]
- 20 The value of E is checked to be valid. 21 If the value of E is null, a System.NullReferenceException is thrown and no further steps are executed.
- 22 The function member implementation to invoke is determined:
- 23 If the compile-time type of E is an interface, the function member to invoke is the implementation of M provided by the run-time type of the instance referenced by E. 24 This function member is determined by applying the interface mapping rules (§20.4.2) to determine the implementation of M provided by the run-time type of the instance referenced by E.
- 25 Otherwise, if M is a virtual function member, the function member to invoke is the implementation of M provided by the run-time type of the instance referenced by E. 26 This function member is determined by applying the rules for determining the most derived implementation (§17.5.3) of M with respect to the run-time type of the instance referenced by E.
- 27 Otherwise, M is a non-virtual function member, and the function member to invoke is M itself.
- 28 The function member implementation determined in the step above is invoked. 29 The object referenced by E becomes the object referenced by this.
|
Jagger Software Ltd |
Company # 4070126 |
VAT # 762 5213 42 |

