Weird!

  • Thread starter Thread starter Michel Racicot
  • Start date Start date
M

Michel Racicot

I got a REALLY weird behavior...

In the following code,

if (sCurrentToken != "")
{
lstArrayLine.Add (sCurrentToken);
sCurrentToken = "";
}

when sCurrentToken is equal to "" (empty string), the sCurrentToken = "";
line, is EXECUTED!!! (but not the .add ( ) line...)

I traced and I really see the line being executed!!! How can this be
possible!?
 
Michel said:
I got a REALLY weird behavior...

In the following code,

if (sCurrentToken != "")
{
lstArrayLine.Add (sCurrentToken);
sCurrentToken = "";
}

when sCurrentToken is equal to "" (empty string), the sCurrentToken = "";
line, is EXECUTED!!! (but not the .add ( ) line...)

I traced and I really see the line being executed!!! How can this be
possible!?

This is a debugger bug. It shows the line being executed, when in fact
it is not. I can't recall at what point this bug was fixed.
 
I had this problem before. It causes by your Dlls. Remove that part of code,
build it, and then type it again. If it doesn't work do this:

if (sCurrentToken == "")
{
doSomething......
}
else
{
lstArrayLine.Add (sCurrentToken);
sCurrentToken = "";
}

hope it helps

sasha
 
Are you 100% sure your code isn't:

doSomething();

if (sCurrentToken != "")
lstArrayLine.Add (sCurrentToken);
sCurrentToken = "";

doSomethingElse();

Leaving out braces for an if statement is quite common. Given the fact that
you actually indent the code it makes it harder to realize it really is a
mistake. This has happened to me many times.

-JG
 
Back
Top