Re: If 1 = 0 Then .... Serious bug in .NET?!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I assume you are referring to C#.

In C# a single equal sign (=) refers to assignment, as in: x = 7;

But double equal signs (==) refer to comparison, as in: if(x==7)

The reason that if(x=7) returns true is because x = 7 is an expression that
is carried out without error (assign the value of 7 to the variable x).

-Scott

"bob1at7shore" <bob1at7shore@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:96A7DEC8-D022-4122-BD04-0E71C6124194@xxxxxxxxxxxxxxxx
if (1=0) or if (1==0)
?????
Just want to be clear.


"Eivind Gussiås Løkseth" wrote:

Today I noticed something I thought was impossible. I have a piece of
code
that is equal to If 1 = 0 Then. The unbeliavable thing is that this
expression is True! (See the attched image.)

When I noticed it, I got one of my collegues to have a look at it, as I
started to think there was something wrong with my eyes. We both saw the
same thing on my machine, and went to his machine to debug the same piece
of
code there. On his machine everything worked as expected.

I then restarted my computer, cleaned and then rebuilt the whole
solution,
but the error was still there! The next natural thing to do before bying
a
new computer, is to delete all source code in the local workspace, and
then
get all the latest source from TFS again. That actually fixed my problem.
But I still wonder how this can be possible.



.



Relevant Pages

  • Re: Debug and break point problem - There is no source code available
    ... manually recreate all the classes and then paste the code in... ... I, too, moved the source code from one ... > I started a new project and confirmed that I can debug it. ... >> I had to manually change the reference in the Solution properties. ...
    (microsoft.public.dotnet.general)
  • Re: Unable to DEbug the Driver in the user mode
    ... I have Printer driver code which uses uniDrv & OEMUI code. ... ANOTHER INTEROP dLL WHICH TRANSFER THE BYTE ARRAY TO .nET ... I am getting some information about the debug content ... but I am not able to debug source code line by line. ...
    (microsoft.public.development.device.drivers)
  • Re: Big problems with glibc - how to debug?
    ... >> kernel services back ported to the Red Hat 2.4 kernels. ... Hat installs. ... this that I can debug with source code;-) ... > have a one-line change in source code which triggers the problem. ...
    (comp.os.linux.development.apps)
  • Re: debugging in release mode
    ... The idea that source code was in the .exe was my misconception. ... The alert is a callback. ... SInce I now know that it is not giving away any secrets to deliver debug ... and then turn off optimizations and turn on generation of debug ...
    (microsoft.public.vc.mfc)
  • Re: Seg fault even though address space is accessible
    ... There's a guy around here somewhere who can debug your problem (no ... matter what it is) using only the debugger. ... debugger and not seeing the source code. ... I did extend the position held by one of the trolls that the debugger ...
    (comp.lang.c)