…where Resharper warned that both the casts to Object were redundant and offered a “Quick-fix” (red light bulb) to “Remove cast”. Well, doing that to one of the casts results in a compile error so you have to manually change the other; but what it’s suggesting is this:

if(myClass1 != myClass2)

This completely changes the output of my application from “not equal” to ”equal”. What Resharper doesn’t know (or doesn’t care to check) is that removing those casts switches from a reference comparison to a value comparison and may have different results. What I wrote with the original code was to test if the two references referenced the same object. The default behaviour of a class is to do a reference check; but I’ve overloaded operator== (and operator !=) to perform a value comparison (I’ve left out the lovely bits that truly gives MyClass value semantics for clarity).

So, when Resharper offers to change your code, be sure you know side-effects of that change before you let it do it. You could introduce a nasty bug.