In this article I will explain how to put conditional breakpoints to avoid debugging continuously particularly in loops to find a particular value inside a loop.
I have used the below code to explain that.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
int j = 0;
for (int i = 0; i <= 20; i++)
j = i;
}
Now put breakpoint on the line where j=i; is written
Now right click on that breakpoint. Click Condition
Enter i==6 in Condition textbox and click ok.
You will see a plus sign will appear in breakpoint.
Now run the code and you will see that breakpoint will hit when i is equals to 6
The above stuff is helpful when we found ourself repeatedly stepping inside loop during debugging, and then we wait to get to a particular loop value .So with Conditional Breakpoints,we can avoid that tidy waiting.Happy Reading.!
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18