Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a null statement to hang a breakpoint on
Message
From
10/08/2006 15:01:51
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Need a null statement to hang a breakpoint on
Miscellaneous
Thread ID:
01144613
Message ID:
01144613
Views:
59
This is a trivial question, but it will save me a lot of time debugging.

A lot of the time, I want to set a breakpoint after a line when there isn't a following line in the same scope. A common example is something like:
    for (int yearIndex = 0; yearIndex < totalYears; yearIndex++)
    {
	calendar[yearIndex] = new CalendarItem();
	calendar[yearIndex].Weeks = Year.GetWeeks(yearIndex);
    }
and I want to break after calendar[yearIndex].Weeks has been set. I could break on the line itself, step past it, and then examine the value in the watch or let the debugger step onto the yearIndex++ statement and hover my mouse, but it is more work when I am going to be examining the value a lot.

What I have been doing is adding a pointless continue statement, i.e.,
    for (int yearIndex = 0; yearIndex < totalYears; yearIndex++)
    {
	memento[yearIndex] = new RetirementProjectionRecord();
	memento[yearIndex].Ages = this.RetirementProjection[yearIndex].Ages;
	continue;
    }
that I can put a break point on. This is convenient inside a for-loop, but outside, I have been typing the pointless line,
    int x = 0; x++;
to have a place to hang a breakpoint, often so I can break before the flow of control leaves a code block and I lose access to variables local to the code block scope.

(I add x++; so I don't get a compiler warning about x being assigned a value but never used.) If anyone else knows of a briefer statement that I would feel compelled to delete out later, I would appreciate it. I think the C++ allows void or null or some such. I would prefer something that I wouldn't feel compelled to remove later and was more obviously nothing to other people viewing my code.
David S. Alexander
Kettley Publishing
20271 SW Birch Street, 2nd Floor
Newport Beach, CA 92660-1752
Next
Reply
Map
View

Click here to load this message in the networking platform