'NullReferenceException was unhandled' in C#

260 Views Asked by At

I am having a nullreferenceexception error in my code in this line:

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

Please tell me what i am doing wrong?

Thanks

1

There are 1 best solutions below

0
On

Frustum is probably null. Use a debugger and check it. You could do something like this to prevent null pointer exceptions

if(Frustum != null)
    return (Frustum.Contains(sphere) != ContainmentType.Disjoint);
return false;