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.5 Primary expressions
14.5.5 Invocation expressions
14.5.5.1 Method invocations
Paragraph 11 For a method invocation, the primary-expression of the invocation-expression must be a method group. 2 The method group identifies the one method to invoke or the set of overloaded methods from which to choose a specific method to invoke. 3 In the latter case, determination of the specific method to invoke is based on the context provided by the types of the arguments in the argument-list.
Paragraph 21 The compile-time processing of a method invocation of the form M(A), where M is a method group and A is an optional argument-list, consists of the following steps: - 2 The set of candidate methods for the method invocation is constructed. 3 Starting with the set of methods associated with M, which were found by a previous member lookup (§14.3), the set is reduced to those methods that are applicable with respect to the argument list A. 4 The set reduction consists of applying the following rules to each method T.N in the set, where T is the type in which the method N is declared:
- 5 If N is not applicable with respect to A (§14.4.2.1), then N is removed from the set.
- 6 If N is applicable with respect to A (§14.4.2.1), then all methods declared in a base type of T are removed from the set.
- 7 If the resulting set of candidate methods is empty, then no applicable methods exist, and a compile-time error occurs. 8 If the candidate methods are not all declared in the same type, the method invocation is ambiguous, and a compile-time error occurs (this latter situation can only occur for an invocation of a method in an interface that has multiple direct base interfaces, as described in §20.2.5).
- 9 The best method of the set of candidate methods is identified using the overload resolution rules of §14.4.2. 10 If a single best method cannot be identified, the method invocation is ambiguous, and a compile-time error occurs.
- 11 Given a best method, the invocation of the method is validated in the context of the method group: If the best method is a static method, the method group must have resulted from a simple-name or a member-access through a type. 12 If the best method is an instance method, the method group must have resulted from a simple-name, a member-access through a variable or value, or a base-access. 13 If neither of these requirements are true, a compile-time error occurs.
Paragraph 31 Once a method has been selected and validated at compile-time by the above steps, the actual run-time invocation is processed according to the rules of function member invocation described in §14.4.3. [Note: The intuitive effect of the resolution rules described above is as follows: To locate the particular method invoked by a method invocation, start with the type indicated by the method invocation and proceed up the inheritance chain until at least one applicable, accessible, non-override method declaration is found. Then perform overload resolution on the set of applicable, accessible, non-override methods declared in that type and invoke the method thus selected. end note] |
Jagger Software Ltd |
Company # 4070126 |
VAT # 762 5213 42 |

