Microsoft 9GD00001 Computer Accessories User Manual


 
354 Microsoft Visual Studio 2010: A Beginner’s Guide
Examining Existing Snippets
Snippets that ship with VS are located at \Program Files\Microsoft Visual Studio 10.0
under a folder for the language (VC#, VB, XML, and more) you need to find a snippet
for. There, you’ll either find one or more folders named with language codes (English is
1033) or a folder named Snippets. For some languages, the language code is at a higher
level and the Snippets folder is under that or vice versa; regardless, you’ll be looking for
the Snippets folder that contains items with a .snippet file extension. The file path for C#
is \Program Files\Microsoft Visual Studio 10.0\VC#\Snippets\1033. Beneath the Snippets
folder, you’ll see additional folders that serve to categorize other snippets.
We’re going to open the for snippet because it contains several features that give
you a good idea of how snippets work. It might help if you open a blank file by pressing
CTRL-N, selecting Visual C# Class, and naming the file anything you want, and try the for
snippet before going further; it will give you a good idea of what the snippet is supposed to
be doing. Alternatively, you can review the description of the for snippet in Chapter 2.
The .snippet extension is registered with VS, so you can double-click the for.snippet file
in the Snippets folder and it will open in VS. Listing 12-1 shows what this file looks like.
Listing 12-1 Inside the for snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns=
"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>for</Title>
<Shortcut>for</Shortcut>
<Description>Code snippet for 'for' loop</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>index</ID>
<Default>i</Default>
<ToolTip>Index</ToolTip>
</Literal>