Hi
I am sure that this is a bug in MS VS 2003;
Consider the following code:
----
public static void Main() {
int i=1;
int j=1;
object a=1;
object b=1;
object c=i;
object d=j;
object e=i;
object f=i;
object g=b;
object h=b;
if (a==b) {
Console.WriteLine("a==b True");
} else {
Console.WriteLine("a==b False");
}
if (c==d) {
Console.WriteLine("c==d True");
} else {
Console.WriteLine("c==d False");
}
if (i==j) {
Console.WriteLine("i==j True");
} else {
Console.WriteLine("i==j False");
}
if (e==f) {
Console.WriteLine("e==f True");
} else {
Console.WriteLine("e==f False");
}
if (g==h) {
Console.WriteLine("g==h True");
} else {
Console.WriteLine("g==h False");
}
}
----
Add watches for the following expressions
a==b
c==d
e==f
g==h
and run the code in Debug mode.
You will see that the watch window shows the values of these expressions as
'True' (also 'True' in the QuickWatch Window) but the debugging always falls
through the 'else' part in the comparison. Heh...? What is this?
Is this a bug...?
I agian say that MS has wrongly implemented the comparison for boxed
variables.
-
Aamir