2012-06-03 72 views
-1

我有在这条线在我的代码一个NullReferenceException错误:“的NullReferenceException是未处理”在C#中

public bool BoundingVolumeIsInView(BoundingSphere sphere) 
    { 
     **return (Frustum.Contains(sphere) != ContainmentType.Disjoint);** 
    } 

请告诉我什么,我做错了什么?

感谢

+0

是'sphere',或'Frustum'可能为空。 – CodesInChaos

+2

我觉得'Frustrum'是'null'。 – ja72

回答

1

Frustum可能是null。使用调试器并检查它。你可以做这样的事情,以防止空指针异常

if(Frustum != null) 
    return (Frustum.Contains(sphere) != ContainmentType.Disjoint); 
return false; 
相关问题