Resharper complains about the following code, saying that the last null check is redundant as the 'expression is always false':
ICloneable data = item as ICloneable;
if (data == null)
throw new InvalidCastException("blah blah, some error message");
object copy = data.Clone();
if (copy == null) // <-- this is where it complains.
return default(T);
How does it know it can never be null?
copy
and if it's null it'll return null and if it's not it'll return not null. – Lauryn