Sdílet prostřednictvím


Declarations Element (IntelliSense Code Snippets)

Specifies the literals and objects that make up the parts of a code snippet that you can edit.

<CodeSnippets>
  <CodeSnippet>
    <Snippet>
      <Declarations>

<Declarations>
    <Literal>... </Literal>
    <Object>... </Object>
</Declarations>

Attributes and Elements

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

Attributes

None.

Child Elements

Element

Description

Literal

Optional element.

Defines the literals of the code snippet that you can edit. There may be zero or more Literal elements in a Declarations element.

Object

Optional element.

Defines the objects of the code snippet that you can edit. There may be zero or more Object elements in a Declarations element.

Parent Elements

Element

Description

Snippet

Contains the references, imports, declarations, and code for the code snippet.

Example

The following code example shows how to declare a literal with an ID element value of SQL and an object with an ID element value of Connection.

<CodeSnippets xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <!-- Insert Header information here. -->
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>SQL</ID>
                    <ToolTip>Replace with a SQL connection string.</ToolTip>
                    <Default>"SQL connection string"</Default>
                </Literal>
                <Object>
                    <ID>Connection</ID>
                    <Type>System.Data.SqlClient.SqlConnection</Type>
                    <ToolTip>Replace with a connection object in your application.</ToolTip>
                    <Default>dcConnection</Default>
                </Object>
            </Declarations>
            <Code Language="CSharp">
                <!-- Insert code here. -->
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

See Also

Concepts

Code Snippets Schema Reference