I'm cleaning up some legacy code and I have found methods which explicitly throw a NullReferenceException
(e.g.: when checking if some properties of a class are null, or checking configuration). As this type of exception is thrown by CLR in case of a null reference, this seems like a very poor choice of an exception for an application to throw explicitly.
My question is - are there any reasons for which a NullReferenceException
would be a good choice for an exception to throw explicitly from code?