更新:2007 年 11 月
指定构成代码段可编辑部分的文本和对象。
<Declarations>
    <Literal>... </Literal>
    <Object>... </Object>
</Declarations>
属性和元素
以下几节描述了属性、子元素和父元素。
属性
无。
子元素
| 元素 | 说明 | 
|---|---|
| 可选的元素。 定义代码段的可编辑文本。Declarations 元素中可能有零个或多个 Literal 元素。 | |
| 可选的元素。 定义代码段的可编辑对象。Declarations 元素中可能有零个或多个 Object 元素。 | 
父元素
| 元素 | 说明 | 
|---|---|
| 包含用于代码段的引用、导入、声明和代码。 | 
示例
下面的代码示例演示如何声明一个 ID 元素值为 SQL 的文本,以及一个 ID 元素值为 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>