Workshop


Quiz

1.

What type of error prevents Visual C# from compiling and running code?

2.

What is another name for a runtime error?

3.

What characters are used to denote a single comment line?

4.

To halt execution at a specific statement in code, you set a _______.

5.

Explain the yellow arrow and red circles that can appear in the gray area in the code editor.

6.

What IDE window would you use to poll the contents of a variable in break mode?

7.

True or False: You must always specify a catch section in a try structure.

Answers

1.

A Build error.

2.

An exception.

3.

Two forward slash characters (//).

4.

Breakpoint

5.

The yellow arrow denotes the next statement to be executed during debugging. The red circles denote break pointsstatements where code execution halts when reached.

6.

The Immediate window.

7.

False. If you omit a catch section, the exception will be ignored.

Exercises

1.

In the code example that sets lngAnswer to the result of a division expression, change lngAnswer from a long to a single (call it sngAnswer). Next, remove the if statements that test the contents of the text box before performing the division. Do you get the same exception(s) that you did when the variable was a long? Why or why not?

2.

Rewrite the code that sets lngAnswer to the result of a division expression so that the code is wrapped in a try structure. Remove the if statement that performs data validation, and create catch sections for the exception that might be thrown.




Sams Teach Yourself Microsoft Visual C# 2005 in 24 Hours, Complete Starter Kit
Sams Teach Yourself Visual C# 2005 in 24 Hours, Complete Starter Kit
ISBN: 0672327406
EAN: 2147483647
Year: N/A
Pages: 248
Authors: James Foxall

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net