I have the following result:
((System.ValueType) 0) != (System.ValueType) 0 && ((System.ValueType) 0) .Equals (0)
The former is a bit unexpected. What should I make of it?
I think that since ValueType is a class, your code creates three different objects (instances). Although, the content of these instances is similar.
Calling ‘!=’ on different objects (references) gives True. (It does not compare the contents of the objects in this case).
Calling Equals returns True because it is designed to compare the contents.
See also: “Boxing”.
8 people are following this question.