Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# How can false == true ? See Picture

I just ran into one of the most mind boggling errors ever. false == true What information would you guys need to confirm/debug this behavior? I've never seen anything like it.

enter image description here

  • VS2008 sp1
  • Debug Mode | Any Cpu
  • IIS 7.5

Edit: I did a clean->rebuild and still the same.

Here's the assembly and registers. I don't know how to read this, but maybe it could help someone else.

like image 464
Arron S Avatar asked Jan 19 '10 22:01

Arron S


2 Answers

I suppose your PDB files are not in phase and you have differences in what's really executed and what Visual Studio sees as a line number. Try rebuilding. We all know that it is impossible to have true = false, or the world as we know it may change :-)

like image 132
Darin Dimitrov Avatar answered Sep 21 '22 05:09

Darin Dimitrov


Does it actually throw the error? The debugger can often highlight the wrong lines if you feed it the wrong pdb, so this could be a false lead. It is also trivial to reproduce using the "immediate" pane to change the value after the test.

If result was a field or a captured variable, it could also be set by external code (perhaps on another thread).

If result wasn't a bool but your own custom type, you could just override ==, or provide a custom true/false operator.

like image 40
Marc Gravell Avatar answered Sep 21 '22 05:09

Marc Gravell