Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Specifies the references, imports, declarations, and code for the code snippet.
<CodeSnippets>
<CodeSnippet>
<Snippet>
<Snippet>
<References>... </References>
<Imports>... </Imports>
<Declarations>... </Declarations>
<Code>... </Code>
</Snippet>
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
Attributes
None.
Child Elements
Element |
Description |
---|---|
Required element. Specifies the code that you want to insert into a documentation file. There must be exactly one Code element in a Snippet element. |
|
Optional element. Specifies the literals and objects that make up the parts of a code snippet that you can edit. There may be zero or one Declarations elements in a Snippet element. |
|
Optional element. Groups individual Import elements. There may be zero or one Imports elements in a Snippet element. |
|
Optional element. Groups individual Reference elements. There may be zero or one References elements in a Snippet element. |
Parent Elements
Element |
Description |
---|---|
Allows you to specify a heading and multiple IntelliSense Code Snippets, which you can insert into Visual Studio code files. |
Example
The following code shows you how to use the Snippet element and its child elements to write a Visual C# code snippet that creates a SqlDataAdapter.
<CodeSnippets xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Create a data adapter</Title>
<Description>Creates a SqlDataAdapter object.</Description>
<Author>Microsoft Corporation</Author>
<Shortcut>createadapter</Shortcut>
</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">
<![CDATA[
daCustomers = new SqlClient.SqlDataAdapter();
selectCommand = new SqlClient.SqlCommand($SQL$);
daCustomers.SelectCommand = selectCommand;
daCustomers.SelectCommand.Connection = $Connection$;
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>