When I write code like this, where obj is a local variable:
if (obj is IMyInterface)
{
var result = (IMyInterface)obj;
// ....
}
Resharper offers to change it into code like this:
var result = obj as IMyInterface;
if (result != null)
{
// ...
}
I prefer the former, as it offers no opportunity for accidental null reference exceptions. What reasons are there for preferring the other form?
Why does Resharper recommend this?