Re: If 1 = 0 Then .... Serious bug in .NET?!
- From: "Scott M." <smar@xxxxxxxxxxxxx>
- Date: Sat, 8 Dec 2007 21:29:53 -0500
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.
.
- Follow-Ups:
- Re: If 1 = 0 Then .... Serious bug in .NET?!
- From: Eivind Gussiås Løkseth
- Re: If 1 = 0 Then .... Serious bug in .NET?!
- From: Alun Harford
- Re: If 1 = 0 Then .... Serious bug in .NET?!
- Prev by Date: Re: Sample Projects
- Next by Date: Re: If 1 = 0 Then .... Serious bug in .NET?!
- Previous by thread: Re: Sample Projects
- Next by thread: Re: If 1 = 0 Then .... Serious bug in .NET?!
- Index(es):
Relevant Pages
|