Throwing exception vs checking null, for a null argument
- by dotnetdev
What factors dictate throwing an exception if argument is null (eg if (a is null) throw new ArgumentNullException() ), as opposed to checking the argument if it is null beforehand.
I don't see why the exception should be thrown rather than checking for null in the first place? What benefit is there in the throw exception approach?
This is for C#/.NET
Thanks