Microsoft 9GD00001 Computer Accessories User Manual


 
48 Microsoft Visual Studio 2010: A Beginner’s Guide
You can identify snippets in the completion list by the torn paper icon. At this point,
you can press the TAB key to complete the namespace keyword. Then press TAB again to
produce a template where you can fill out the highlighted fields. Figure 2-8 shows the
results of creating a namespace snippet by typing n and pressing
TAB, TAB.
As shown in Figure 2-8, you would type in the Namespace name in the highlighted
form field to replace MyNamespace, which is placeholder text. For templates with more
fields, you would press the
TAB key to move between fields. In the case of the namespace
shown in Figure 2-8, there is only one field in the template to complete.
VB offers a couple of ways to add snippets: by typing prefixes or via a pick list. To see
how VB snippets work, place your carat inside of the Module1 module, underneath End
Main (not inside of the Main block). Type Su and press
TAB, and notice that VS creates a
Sub (method) along with a template containing a field for filling out the Sub snippet.
Another way to add VB snippets is to type a ? and press
TAB. You’ll receive a pick list,
as shown in Figure 2-9. You can navigate this pick list to find the snippet you need, as
classified in one of the folders. VB ships with many more built-in snippets than for C#.
Now that you know how to use snippets, let’s move on to the different types of
statements you can have in C# and VB and how snippets work with those statements.
Figure 2-9 VB snippet pick list
Figure 2-8 Filling in the Snippet template