P
Peter Morris [Droopy eyes software]
object a = 5;
object b = 5;
if (a != b)
throw new InvalidOperationException("a != b");
Why is the exception thrown? I guessed it is something to do with boxing
because the following does not throw an exception
object a = 5;
object b = 5;
if (!a.Equals(b))
throw new InvalidOperationException("a != b");
but why doesn't the boxed object use the Equals method of the object it
contains?
object b = 5;
if (a != b)
throw new InvalidOperationException("a != b");
Why is the exception thrown? I guessed it is something to do with boxing
because the following does not throw an exception
object a = 5;
object b = 5;
if (!a.Equals(b))
throw new InvalidOperationException("a != b");
but why doesn't the boxed object use the Equals method of the object it
contains?