the below is the line that does the cast
TwoDPoint p = obj as TwoDPoint
the difference with the "normal" cast is that using "As" it doesn't raise an exception if the object is not "castable". In this case if "p" is not a TwoDPoint
Type is not gonna raise an exception (cast not valid) but return null.
if ((System.Object)p == null) // <-- wtf?
{
return false;
}
this code check if the cast went fine if not p should be null for the reason above