المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Best Practices: Checking For Null Objects After Initializing



C# Programming
05-21-2010, 06:50 PM
I have a senior developer that consistently checks for null after initializing an object...

CustomObject tmp = new CustomObject();

if (tmp == null)
{
throw new NullReferenceException();
}

I personally don't see the need to do this. Can anyone explain if this is a good/bad/old practice?

Thanks in advance.