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
Importsstatement can import one namespace.A module can have have as many
Importsstatements as needed.Importsstatements are used to import names from other projects and assemblies, as well as from namespaces in the current project.Importsstatements must be placed in a module before references to any identifiers (e.g., variables, classes, procedures, functions, etc.).namespacemust 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
aliasnameis absent from anImportsstatement, types in that namespace can be referenced without qualification.If
aliasnameis present in anImportsstatement, types in that namespace must be qualified withaliasnamein order to be accessible.The name
aliasnamemust not be assigned to any other member within the module.If
elementis specified, it can be the name of an enumeration, structure, class, or module within the namespace. If specified, this ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access