This topic has not yet been rated - Rate this topic

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:

  1. For each nested type containing the name reference, starting from the innermost type and going to the outermost, if R matches the name of an accessible nested type in the current type, then the unqualified name refers to that type.
  2. For each nested namespace containing the name reference, starting from the innermost namespace and going to the outermost namespace, do the following:
    1. If R matches the name of an accessible type or nested namespace in the current namespace, then the unqualified name refers to that type or nested namespace.
    2. If the namespace contains one or more accessible standard modules, and R matches the name of an accessible nested type in exactly one standard module, then the unqualified name refers to that nested type. If R matches the name of accessible nested types in more than one standard module, a compile-time error occurs.
  3. If the source file has one or more import aliases, and R matches the name of one of them, then the unqualified name refers to that import alias.
  4. If the source file containing the name reference has one or more imports:
    1. If R matches the name of a namespace or an accessible type in exactly one import, then the unqualified name refers to that namespace or type. If R matches 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.
    2. If the imports contain one or more accessible standard modules, and R matches the name of an accessible nested type in exactly one standard module, then the unqualified name refers to that type. If R matches the name of accessible nested types in more than one standard module, a compile-time error occurs.
  5. If the compilation environment defines one or more import aliases, and R matches the name of one of them, then the unqualified name refers to that import alias.
  6. If the compilation environment defines one or more imports:
    1. If R matches the name of a namespace or an accessible type in exactly one import, then the unqualified name refers to that namespace or type. If R matches the name of namespace or an accessible type member in more than one import, a compile-time error occurs.
    2. If the imports contain one or more accessible standard modules, and R matches the name of an accessible nested type in exactly one standard module, then the unqualified name refers to that type. If R matches the name of accessible nested types in more than one standard module, a compile-time error occurs.
  7. 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

Did you find this helpful?
(1500 characters remaining)