Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need a null statement to hang a breakpoint on
Message
De
10/08/2006 15:01:51
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Need a null statement to hang a breakpoint on
Divers
Thread ID:
01144613
Message ID:
01144613
Vues:
56
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform