Catching NullReferenceException should not be used as an alternative to checks and assertions for preventing dereferencing a null pointer.

Check if the variable is null before dereferencing it.

The following example class, findPerson returns null if the person is not found.

The following example has been updated to ensure that any null return values are handled correctly.