[Solved] Weird behavior if() with false statement evaluates to true C#


After all the answer was hidden in a comment by @Eric Lippert

Are you compiling release or debug? The position of the current line when debugging the release build is sometimes wrong. Is the exception actually thrown?

The exception was not thrown really. Although I was debugging the debug build the fact is that the current line entered the if even when the condition statement was false, although the line did not execute.

When debugging I interpreted that that line was next to be executed. Curiously when removing the try catch block below then the debugging line step over.

I am really embarrassed with you guys but the fact is that I was so used to be debugging and to consider the highlighted line to be the next to be executed that well…

Nevertheless I would appreciate if someone could explain why this happens.

1

solved Weird behavior if() with false statement evaluates to true C#