Microsoft 9GD00001 Computer Accessories User Manual


 
58 Microsoft Visual Studio 2010: A Beginner’s Guide
itself, so we call it a clause because it can be part of an if statement. An example of an
else clause is shown here:
C#:
if (result > 48)
{
Console.WriteLine("result is > 48");
}
else
{
Console.WriteLine("result is <= 48");
}
VB:
If result > 48 Then
Console.WriteLine("Result is > 48")
Else
Console.WriteLine("Result is <= 48")
End If
As the preceding example shows, if result is not greater than 48, then it must be less
than or equal to 48.
if and else Snippets
The if snippet creates a template for you to build an if statement. To use the if snippet, type
if and press
TAB, TAB; you’ll see the template in Figure 2-11 for C# or Figure 2-12 for VB.
Figure 2-11 The C# if statement snippet template
Figure 2-12 The VB if statement snippet template