Microsoft 9GD00001 Computer Accessories User Manual


 
60 Microsoft Visual Studio 2010: A Beginner’s Guide
is required. When the program executes a break statement, it stops executing the switch
statement and begins executing the next statement after the last curly brace of the switch
statement.
For the VB example, the Select Case statement uses name as the condition and
executes code based on which case matches name. The Case Else code block will run if
no other cases match.
Switch Statement Snippets
There are two scenarios for switch statement snippets: a minimal switch statement and an
expanded switch with enum cases. First, try the minimal switch statement by typing sw
and pressing
TAB, TAB, resulting in the switch statement in Figure 2-13.
You would replace the switch_on in Figure 2-13 with a value you want to use in the
switch statement. After pressing
ENTER, you’ll see the snippet expand to a switch statement
with a default case, as follows:
switch (name)
{
default:
break;
}
VB Select statements work similar to the C# switch; type Se and press TAB, TAB; you’ll
see the VB template shown in Figure 2-14.
Figure 2-13 A switch snippet template
Figure 2-14 The Select Case snippet template