C# == operator in Immediate window behaves differently than at run-time
Posted
by Damiano
on Stack Overflow
See other posts from Stack Overflow
or by Damiano
Published on 2010-05-25T13:30:41Z
Indexed on
2010/05/25
13:41 UTC
Read the original article
Hit count: 196
Try the following in the Immediate window:
object a1 = "a";
object a2 = "a";
a1==a2 // outputs false
and you'll see that a1 == a2
outputs false
.
However, at runtime in either a window app or console, you'll get true
:
object t1 = "a";
object t2 = "a";
MessageBox.Show((t1 == t2).ToString()); // outputs true
The runtime behavior is consistent with the definition for the ==
operator and strings.
Does anybody know if this a bug in the Immediate window?
© Stack Overflow or respective owner