This documentation is archived and is not being maintained.

Code Element (IntelliSense Code Snippets) 

Provides a container the short code blocks of IntelliSense Code Snippets.

<Code Language="Language"
    Kind="method body/method decl/type decl/page/file/any"
        Code to insert

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


Attribute Description


Optional attribute.

Specifies the delimiter used to describe literals and objects in the code. By default, the delimiter is $.


Optional attribute.

Specifies the kind of code that the snippet contains and, therefore, the location at which a code snippet must be inserted for the code snippet to compile. The values available are method body, method decl, type decl, file, and any. For more information, see the section "Kind Attribute" in the following table.


Required attribute.

Specifies the language of the code snippet. The values available are VB, CSharp, VJSharp, or XML. For more information, see the section "Language Attribute" in the following table.

Kind Attribute

Value Description

method body

Specifies that the code snippet is a method body, and therefore, must be inserted inside a method declaration.

method decl

Specifies that the code snippet is a method, and therefore, must be inserted inside a class or module.

type decl

Specifies that the code snippet is a type, and therefore, must be inserted inside a class, module, or namespace.


Specifies that the snippet is a full code file. These code snippets can be inserted alone into a code file, or inside a namespace.


Specifies that the snippet can be inserted anywhere. This tag is used for code snippets that are context-independent, such as comments.

Language Attribute

Value Description


Identifies a Visual Basic code snippet.


Identifies a Visual C# code snippet.


Identifies a Visual J# code snippet.


Identifies an XML code snippet.

Child Elements


Parent Elements

Element Description


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

A text value is required.

This text specifies the code, along with the literals and objects, that you can use when this code snippet is inserted into a project.

Use the reserved word $end$ in the text of the Code element to mark the location to place the cursor after the code snippet is inserted.

The Code element of the following code snippet shows how to write a Visual C# code snippet that creates a SqlDataAdapter. The literal and object defined in the Declarations element are referenced in the Code element by the value of their ID element. In this example, the literal is referenced as $SQL$ and the object is referenced as $Connection$.

<CodeSnippets xmlns="">
    <CodeSnippet Format="1.0.0">
            <Title>Create a data adapter</Title>
            <Description>Creates a SqlDataAdapter object.</Description>
            <Author>Microsoft Corporation</Author>
                    <ToolTip>Replace with a SQL connection string.</ToolTip>
                    <Default>"SQL connection string"</Default>
                    <ToolTip>Replace with a connection object in your application.</ToolTip>
            <Code Language="CSharp">
                    daCustomers = new SqlClient.SqlDataAdapter();
                    selectCommand = new SqlClient.SqlCommand($SQL$);
                    daCustomers.SelectCommand = selectCommand;
                    daCustomers.SelectCommand.Connection = $Connection$;