在我的代码中,我经常遇到这样的情况:publicvoidMyMethod(stringdata){AnotherClassobjectOfAnotherClass=GetObject(data);if(objectOfAnotherClass==null)thrownewWhatExceptionType1("objectOfAnotherClassisnull.");if(objectOfAnotherClass.SomeProperty假设GetObject使用了一些不受我控制的外部库,如果没有data的对象,这个库返回null存在并将负SomeProperty视为有效状态,因此不