4.7.2 Unqualified Name Resolution
Visual Studio .NET 2003
Given an unqualified name R, the following steps describe how to determine to which namespace or type an unqualified name refers:
- For each nested type containing the name reference, starting from the innermost type and going to the outermost, if
Rmatches the name of an accessible nested type in the current type, then the unqualified name refers to that type. - For each nested namespace containing the name reference, starting from the innermost namespace and going to the outermost namespace, do the following:
- If
Rmatches the name of an accessible type or nested namespace in the current namespace, then the unqualified name refers to that type or nested namespace. - If the namespace contains one or more accessible standard modules, and
Rmatches the name of an accessible nested type in exactly one standard module, then the unqualified name refers to that nested type. IfRmatches the name of accessible nested types in more than one standard module, a compile-time error occurs.
- If
- If the source file has one or more import aliases, and
Rmatches the name of one of them, then the unqualified name refers to that import alias. - If the source file containing the name reference has one or more imports:
- If
Rmatches the name of a namespace or an accessible type in exactly one import, then the unqualified name refers to that namespace or type. IfRmatches the name of a namespace or accessible type members in more than one import and all are not the same entity, a compile-time error occurs. - If the imports contain one or more accessible standard modules, and
Rmatches the name of an accessible nested type in exactly one standard module, then the unqualified name refers to that type. IfRmatches the name of accessible nested types in more than one standard module, a compile-time error occurs.
- If
- If the compilation environment defines one or more import aliases, and
Rmatches the name of one of them, then the unqualified name refers to that import alias. - If the compilation environment defines one or more imports:
- If
Rmatches the name of a namespace or an accessible type in exactly one import, then the unqualified name refers to that namespace or type. IfRmatches the name of namespace or an accessible type member in more than one import, a compile-time error occurs. - If the imports contain one or more accessible standard modules, and
Rmatches the name of an accessible nested type in exactly one standard module, then the unqualified name refers to that type. IfRmatches the name of accessible nested types in more than one standard module, a compile-time error occurs.
- If
- Otherwise, a compile-time error occurs.
Note An implication of this resolution process is that type members do not shadow namespaces or types when resolving namespace or type names.
See Also
4.7 Type and Namespace Names | 11.12.3 Operator Resolution | 11.8.1 Overloaded Method Resolution | 6.3 Imports Statement