VS.NET Bug Followup - Or is True == 1
Allan Bogh left a comment on my previous post about the VS.NET debugger and quickwatch windows giving erroneous values:
Ahh, you miss the underlying meaning of 1 in o1 = 1. When you tell a C++/javascript/php/perl/every other high-level language that a variable (o1) is 1, you are only telling the system that it's true, not that it actually equals 1. When you tell two variables that they are "true" this, in no way, means that o1 == o2. If you figure that when you tell a variable that it ="a string", you are only giving the string an alias. Two different aliases with the same string are equal, but those two aliases by themself are not equal.
At the time he left the comment it was not clear that I was talking about C#, I've updated the post since then to reflect the specifics.
However, it is interesting to point out that in C# true and 1 are in fact not the same thing unlike it's ancestors. From the docs:
In C++, a value of type bool can be converted to a value of type int; in other words, false is equivalent to zero and true is equivalent to nonzero values. In C#, there is no conversion between the bool type and other types.
In fact the following expression will not compile in C#:
if (true == 1) {}
I actually like this feature because to me true is different than non-zero.