O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Imports Statement

Syntax

Imports [aliasname = ] namespace [.element]
aliasname (optional; String literal)

The name by which the namespace will be referenced in the module

namespace (required; String literal)

The name of the namespace being imported

element (optional)

The name of an element in the namespace

Description

Imports namespaces or parts of namespaces, making their members available to the current module

Rules at a Glance

  • A single Imports statement can import one namespace.

  • A module can have have as many Imports statements as needed.

  • Imports statements are used to import names from other projects and assemblies, as well as from namespaces in the current project.

  • Imports statements must be placed in a module before references to any identifiers (e.g., variables, classes, procedures, functions, etc.).

  • namespace must be a fully qualified namespace name, even if you use the /rootnamespace compiler option or supply a value for the “Root namespace” text box in the General tab of a project’s Properties dialog in Visual Studio.

  • If aliasname is absent from an Imports statement, types in that namespace can be referenced without qualification.

  • If aliasname is present in an Imports statement, types in that namespace must be qualified with aliasname in order to be accessible.

  • The name aliasname must not be assigned to any other member within the module.

  • If element is specified, it can be the name of an enumeration, structure, class, or module within the namespace. If specified, this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required