Why do this:
// If parameter cannot be cast to Point return false.
TwoDPoint p = obj as TwoDPoint;
if ((System.Object)p == null)
{
return false;
}
Instead of this:
// If parameter cannot be cast to Point return false.
TwoDPoint p = obj as TwoDPoint;
if (p == null)
{
return false;
}
I don’t understand why you’d ever write ((System.Object)p)?
Regards,
Dan
You cast to
objectwhen you don’t know or can’t be sure whether the original class has overriddenoperator ==:This code outputs only
"ae is null", which is obviously not the case. The cast toobjectavoids theAlwaysEqualclass’soperator ==and is therefore a true reference check againstnull.