For example, you usually do not want the parameters in the constructor to be zero, so itβs very normal to see something like
if (someArg == null) { throw new ArgumentNullException(nameof(someArg)); } if (otherArg == null) { throw new ArgumentNullException(nameof(otherArg)); }
This is a bit cluttered with code.
Is there a better way to test the argument list argument than this?
Something like, "check all the arguments and throw an ArgumentNullException if any of them is null and provides you with arguments that were empty.
By the way, with respect to recurring claims questions, this is not about labeling the arguments with attributes or something that is built-in, but that some people call it Guard Clauses to ensure that the object receives initialized dependencies.
constructor c # arguments
Superjmn
source share