When the value of a normal parameter is unacceptable (and the requirements can't be checked completely at compile time), we check at runtime and throw an ArgumentException
if the check fails.
When the "value" of a type parameter is similarly unacceptable, what kind of exception do we throw? Are there any guidelines on this?
(Note: If I try ArgumentException
, ReSharper wants to complain – which makes me think there may be another kind of exception that's recommended for this.)
Best Answer
There isn't a native exception in the .NET Framework for "Invalid Type Parameter Argument." Jon Skeet asked about this on Stack Overflow, and ultimately decided to write his own: