1322 Visual Studio .NET Debugger Appendix D D.5 (Make my own web site)
1322 Visual Studio .NET Debugger Appendix D D.5 Additional Method Debugging Capabilities In programs with many methods, it is often difficult to determine which methods may have been involved in incorrect calculations that resulted in a logic error. To simplify this process, the Visual Studio debugger includes tools for analyzing methods and method calls. We demonstrate some method-debugging tools in the following example (Fig. D.16). The Call Stack window contains the program s method call stack, which allows the programmer to determine the exact sequence of calls that lead to the current method and to examine calling methods on the stack. This window allows the programmer to determine the flow of control in the program that resulted in the execution of the current method. For example, a breakpoint is inserted in MyMethod, the call stack in (Fig. D.17) indicates that the program called method Mainfirst, followed by MyMethod. 1 // Fig. D.16: MethodDebugExample.cs 2 // Demonstrates debugging methods. 3 4 using System; 5 6 namespace Debug 7 { 8 9 // provides methods on which to demonstrate 10 // Visual Studio s debug tools 11 class MethodDebug 12 { 13 // entry point for application 14 static void Main( string[] args ) 15 { 16 // display MyMethod return values 17 for( int i = 0; i < 10; i++ ) 18 Console.WriteLine( MyMethod( i ) ); 19 20 Console.ReadLine(); 21 } // end method main 22 23 // perform calculation 24 static int MyMethod( int x ) 25 { 26 return ( x * x ) - ( 3 * x ) + 7; 27 } // end method MyMethod 28 29 // method with logic error 30 static int BadMethod( int x ) 31 { 32 return 1 / ( x -x ); 33 } // end method BadMethod 34 35 } // end class MethodDebug 36 37 } // end namespace Debug Fig. D.16 Fig. D.16Fig. D.FiFi16g. D.16g. D.16Debugging methods.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.