0L.Equals(0) // true
This enables the long.Equals method, which takes a long parameter as a parameter. The actual expression for the parameter is indicated by int . That int implicitly converted to long , so long 0 is passed, which is equal to another value.
((object)0L).Equals(0L) // true ((object)0L).Equals(0) // false
The long box here prevents overloading long.Equals and leaves only overloading object.Equals , which takes an object parameter. Since the object parameter is both fragments, each of which has long and int respectively, both are obtained in a box. The object.Equals implementation also checks the type of the parameter and considers that any objects of different types are not equal. The first of these two fragments skips the check, after which it continues to check the values, considering them equal. In the second fragment there is no check, the result is false .
Servy source share