Home > DeveloperSection > Forums > How to debug a C# program
Htwe Htwe
Htwe Htwe

Total Post:3

Points:21
Posted on    April-08-2013 11:14 AM

 C# C# 
Ratings:


 1 Reply(s)
 1056  View(s)
Rate this:
Hi All,

Please explain to me how to debug a C# program using visual studio with examples.

Thanks And Regards


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    April-09-2013 8:19 AM

Hi Htwe!

For debugging you application follow the below steps

Step 1: Breakpoints

Breakpoint is used to notify debugger where and when to pause the execution of program. You can put a breakpoint in code by clicking on the side bar of code or by just pressing F9 at the front of the line. 

Step 2: Step Over

After debugger hits the breakpoint, you may need to execute the code line by line. "Step Over" [ F10 ] command is used to execute the code line by line. This will execute the currently highlighted line and then pause. If you select F10 while a method call statement is highlighted, the execution will stop after the next line of the calling statement.

Step 3: Step Into

This is similar to Step Over. The only difference is, if the current highlighted section is any methods call, the debugger will go inside the method. Shortcut key for Step Into is "F11". 

Step 4: Step Out

This is related when you are debugging inside a method. If you press the Shift - F11 within the current method, then the execution will complete the execution of the method and will pause at the next statement from where it called. 

Don't want to miss updates? Please click the below button!

Follow MindStick