Basic Question.

Lak

Newcomer
Joined
Aug 4, 2003
Messages
2
Pls take a look at this peice of code :

int a=1;
int b=2;
try
{
if (a==b)
{
Console.WriteLine("wrong"); //This loop should never be enetred.
}
}
catch(Exception e)
{}

The if loop should never be entered, but it is entered inside the try block.Could someone tell me why???


Thanks.
 
When I tried it in the debugger it stepped through as I would expect, after the if(a==b) it exited the if statement block and the message was never written to the screen.
Are you sure you have the code exactly the same not if (a=b) for example?
 
yes, the message is never written to the screen, since the statement is never executed. but it enters the loop while i am debugging.i guess for some reason my debugger shows the line being debugged as one line ahead of what it actually is doing.Do you know why???


Thanks
 
You actually see the debugger go to the line
C#:
 Console.WriteLine("wrong"); //This loop should never be enetred.

if so look in the debug directory and delete any *.pdb files you see there and do a rebuild and try the debugger again.
 
I've had that happen as well when I am stepping through something in debug, it highlights the line, but doesn't execute....
 
Back
Top