Dela via


Namespace Element (IntelliSense Code Snippets)

Specifies the namespace that must be imported for the code snippet to compile and run.

<CodeSnippets>
  <CodeSnippet>
    <Snippet>
      <Imports>
        <Import>
          <Namespace>

<Namespace>
    Namespace
</Namespace>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

Child Elements

None.

Parent Elements

Element

Description

Import

Imports the specified namespace.

Text Value

A text value is required.

This text specifies a namespace that the code snippet assumes is imported.

Remarks

The Namespace element is only supported for Visual Basic projects.

The namespace specified in the Namespace element is automatically added to an Imports Statement (.NET Namespace and Type) statement at the beginning of the code, if it does not already exist.

Example

The following code example imports the System.Data namespace.

<CodeSnippets xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <!-- Insert Header information here. -->
        </Header>
        <Snippet>
            <Imports>
                <Import>
                    <Namespace>System.Data</Namespace>
                </Import>
            </Imports>
            <Declarations>
                <!-- Insert literal and object declarations here. -->
            </Declarations>
            <Code Language="VB">
                <!-- Insert code here. -->
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

See Also

Concepts

Code Snippets Schema Reference