Appendix D Visual Studio .NET Debugger 1317 By

Appendix D Visual Studio .NET Debugger 1317 By entering the variables and expressions that are relevant to a program s logic error, programmers can trace incorrect values to the source of the error and eliminate it. For example, to debug the program in Fig. D.2, we might enter the expression i*x in the Watch window. When we reach the breakpoint for the first time, the expression has a value 100 instead of 90, which indicates a logic error in our program. This occurs because the loop at lines 17 18 started multiplying x by 10as opposed to multiplying by 9. We subtract 1from the initial value that the forloop assigns to i(i.e., change 10to 9) to correct the error. If a Name field in the Watch window contains a variable name, the variable s value can be modified for debugging purposes. To modify a variable s value, click its value in the Value field and enter a new value. Any modified value appears in red. If an expression is invalid, an error appears in the Value field. For example, Variable- ThatDoesNotExist is not an identifier used in the program (fourth line in Fig. D.7). Therefore, Visual Studio .NET issues an error message in the Value field. To remove an expression, select it and press Delete. Visual Studio also provides the Locals, Autos and This windows (Fig. D.8), which are similar to the Watch window, except the programmer does not specify their contents. The Locals window displays the name and current value for all the variables that have block scope in the method containing the current statement (indicated by the yellow arrow in Fig. D.6). The Autos window displays the variables and values of the current statement and the previous statement. Variables can be changed in either window by clicking the appropriate Value field and entering a new value. The This window displays data that has class scope for an object. If the program is inside a staticmethod (such as method Main in a console application), the This window is empty. Fig. D.8 Fig. D.8Fig. D.FiFi8g. D.8g. D.8Autos, Locals and This windows.
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Leave a Reply