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.3 Member lookup
Paragraph 11 A member lookup is the process whereby the meaning of a name in the context of a type is determined. 2 A member lookup may occur as part of evaluating a simple-name (§14.5.2) or a member-access (§14.5.4) in an expression.
Paragraph 21 A member lookup of a name N in a type T is processed as follows:
Paragraph 31 For member lookups in types other than interfaces, and member lookups in interfaces that are strictly single-inheritance (each interface in the inheritance chain has exactly zero or one direct base interface), the effect of the lookup rules is simply that derived members hide base members with the same name or signature. 2 Such single-inheritance lookups are never ambiguous. 3 The ambiguities that can possibly arise from member lookups in multiple-inheritance interfaces are described in §20.2.5.
- 2 First, the set of all accessible (§10.5) members named N declared in T and the base types (§14.3.1) of T is constructed. 3 Declarations that include an override modifier are excluded from the set. 4 If no members named N exist and are accessible, then the lookup produces no match, and the following steps are not evaluated.
- 5 Next, members that are hidden by other members are removed from the set. 6 For every member S.M in the set, where S is the type in which the member M is declared, the following rules are applied:
- 7 If M is a constant, field, property, event, type, or enumeration member, then all members declared in a base type of S are removed from the set.
- 8 If M is a method, then all non-method members declared in a base type of S are removed from the set, and all methods with the same signature as M declared in a base type of S are removed from the set.
- 9 Finally, having removed hidden members, the result of the lookup is determined:
- 10 If the set consists of a single non-method member, then this member is the result of the lookup.
- 11 Otherwise, if the set contains only methods, then this group of methods is the result of the lookup.
- 12 Otherwise, the lookup is ambiguous, and a compile-time error occurs (this situation can only occur for a member lookup in an interface that has multiple direct base interfaces).
|Jagger Software Ltd|
|Company # 4070126|
|VAT # 762 5213 42|