I was reading this post where the answerer mentioned he prefered ArgumentNullException
over NullReferenceException
.
MSDN mention that for NullReferenceException
:
The exception that is thrown when there is an attempt to dereference a null object reference.
On ArgumentNullException
they say:
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
The answerer seems to say that you can use either.
Is there any reason or any case where I should choose one over the other?
P.S.
I know this question could be opinion based. I want fact, context and situation. I am not interested by personnal preference.